import { Hono } from 'hono'
import { IndexPage, ProfileExamplesPage, ButtonExamplesPage, NavigationExamplesPage } from './examples/ssr/pages'
import { LandingPage } from './examples/ssr/landing'
import { styles, stylesToCSS } from './src'

const app = new Hono()

app.get('/', c => c.html(<LandingPage />))

app.get('/ssr', c => c.html(<IndexPage />))

app.get('/ssr/profile', c => c.html(<ProfileExamplesPage />))

app.get('/ssr/buttons', c => c.html(<ButtonExamplesPage />))

app.get('/ssr/navigation', c => c.html(<NavigationExamplesPage />))

app.get('/styles', c => c.text(stylesToCSS(styles)))

app.get('/spa/*', async c => c.html(await Bun.file('./examples/spa/index.html').text()))

app.get('/spa.js', async c => {
  const file = Bun.file('./dist/spa.js')
  return new Response(file, {
    headers: {
      'Content-Type': 'application/javascript',
    },
  })
})

export default {
  port: 3300,
  fetch: app.fetch,
}
