blog/src/index.tsx

36 lines
738 B
TypeScript
Raw Normal View History

2024-07-03 02:35:01 +00:00
import { Hono } from 'hono';
import { jsxRenderer, useRequestContext } from 'hono/jsx-renderer';
import { Page } from '@blog/templates/Page';
import home from '@blog/routes/home';
2024-07-04 02:13:04 +00:00
import posts from '@blog/routes/posts';
import type { SiteMeta } from '@blog/model/SiteMeta';
declare module 'hono' {
interface ContextRenderer {
(content: string|Promise<string>, props: { meta: SiteMeta }): Response;
}
}
2024-07-03 02:35:01 +00:00
const app = new Hono();
// Render the JSX views
2024-07-03 02:35:01 +00:00
app.get(
'*',
jsxRenderer(
2024-07-04 02:13:04 +00:00
({ children, meta }) => {
return (<Page meta={meta}>{children}</Page>);
2024-07-03 02:35:01 +00:00
},
{
docType: true
}
)
);
// read all posts
// create listing of posts
app.route('/', home);
app.route('/posts', posts);
2024-07-03 02:35:01 +00:00
export default app;