blog/src/index.tsx

34 lines
758 B
TypeScript
Raw Normal View History

2024-07-03 02:35:01 +00:00
import { Hono } from 'hono';
2024-07-09 01:37:25 +00:00
import { jsxRenderer } from 'hono/jsx-renderer';
2024-07-03 02:35:01 +00:00
import { Page } from '@blog/templates/Page';
2024-07-09 01:37:25 +00:00
import home from '@blog/handlers/home';
import posts from '@blog/handlers/posts';
import type { SiteMeta } from '@blog/models/SiteMeta';
2024-07-04 02:13:04 +00:00
declare module 'hono' {
interface ContextRenderer {
(content: string|Promise<string>, props: { meta: SiteMeta }): Response;
}
}
2024-07-03 02:35:01 +00:00
2024-07-09 01:37:25 +00:00
const app = new Hono();
2024-07-03 02:35:01 +00:00
2024-07-09 01:37:25 +00:00
// Render the JSX views
app.get(
'*',
jsxRenderer(
({ children, meta }) => <Page meta={meta}>{children}</Page>,
{ docType: true }
)
);
2024-07-03 02:35:01 +00:00
2024-07-09 01:37:25 +00:00
console.log({ message: "Bootstrapping the routes..." });
app.route('/', home);
app.route('/posts', posts);
2024-07-03 02:35:01 +00:00
2024-07-09 01:37:25 +00:00
export default {
port: process.env.APP_PORT || 3000,
fetch: app.fetch
2024-07-07 02:03:40 +00:00
}