Created
June 30, 2026 14:58
-
-
Save yusukebe/afd27a571b50df7a3e119854e0d02fa3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Hono } from 'hono' | |
| import { feedRenderer } from './renderer' | |
| const app = new Hono() | |
| app.get('/feed', feedRenderer({ baseUrl: 'https://example.com' }), (c) => c.render(items, { format: 'atom' })) | |
| export default app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import type { MiddlewareHandler } from 'hono' | |
| import type { Feed } from './feed' | |
| import { serveFeed } from './serve' | |
| import type { FeedInput, ServeFeedOptions } from './types' | |
| declare module 'hono' { | |
| interface ContextRenderer { | |
| (input: FeedInput | Feed, options?: ServeFeedOptions): Response | |
| } | |
| } | |
| export function feedRenderer(defaults: ServeFeedOptions = {}): MiddlewareHandler { | |
| return async (c, next) => { | |
| c.setRenderer((input, options) => serveFeed(c, input, { ...defaults, ...options })) | |
| await next() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment