import { Hono } from 'hono';
import { jsxRenderer, useRequestContext } from 'hono/jsx-renderer';
import { Page } from '@blog/templates/Page';
import { renderHomePage } from '@blog/routes/home';
import { renderPostPage } from '@blog/routes/post';

const app = new Hono();

app.get(
  '*',
  jsxRenderer(
    ({ children }) => {
      return (<Page>{children}</Page>);
    },
    {
      docType: true
    }
  )
);

// read all posts
// create listing of posts

app.get('/', async (c) => {
  return renderHomePage(c);
});

app.get('/posts/:slug', async (c) => {
  return renderPostPage(c);
});

export default app;
