| … | … | @@ -1,28 +1,27 @@ |
| 1 | 1 | import { Hono } from "jsr:@hono/hono"; |
| 2 | | import { serveStatic } from 'jsr:@hono/hono/deno' |
| 3 | | import { marked } from 'https://esm.sh/gh/evbogue/bog5@de70376265/lib/marked.esm.js' |
| 2 | import { serveStatic } from "jsr:@hono/hono/deno"; |
| 3 | import { marked } from "https://esm.sh/gh/evbogue/bog5@de70376265/lib/marked.esm.js"; |
| 4 | 4 | |
| 5 | 5 | import { foot, head } from "./template.js"; |
| 6 | 6 | |
| 7 | 7 | const app = new Hono(); |
| 8 | 8 | |
| 9 | | const readme = await Deno.readTextFile('./README.md') |
| 9 | const readme = await Deno.readTextFile("./README.md"); |
| 10 | 10 | |
| 11 | | app.get('/', async (c) => { |
| 11 | app.get("/", async (c) => { |
| 12 | 12 | const content = ` |
| 13 | 13 | <div id="scroller"> |
| 14 | 14 | <div class='message'> |
| 15 | 15 | ${await marked(readme)} |
| 16 | 16 | </div> |
| 17 | 17 | </div> |
| 18 | | ` |
| 18 | `; |
| 19 | 19 | |
| 20 | | const html = await head('Index') + content + await foot() |
| 21 | | return await c.html(html) |
| 22 | | }) |
| 23 | | |
| 24 | | app.get('/try', async (c) => { |
| 20 | const html = await head("Index") + content + await foot(); |
| 21 | return await c.html(html); |
| 22 | }); |
| 25 | 23 | |
| 24 | app.get("/try", async (c) => { |
| 26 | 25 | const body = `<body> |
| 27 | 26 | <div id='scroller'> |
| 28 | 27 | <div class='message'> |
| … | … | @@ -136,17 +135,20 @@ getbutton.onclick = async () => { |
| 136 | 135 | } |
| 137 | 136 | } |
| 138 | 137 | |
| 139 | | </script>` |
| 138 | </script>`; |
| 140 | 139 | |
| 141 | | const html = await head('Try it') + body + await foot() |
| 142 | | return await c.html(html) |
| 143 | | }) |
| 140 | const html = await head("Try it") + body + await foot(); |
| 141 | return await c.html(html); |
| 142 | }); |
| 144 | 143 | |
| 145 | | app.use('*', serveStatic({ |
| 146 | | root: './', |
| 147 | | onFound: (_path, c) => { |
| 148 | | c.header("Access-Control-Allow-Origin", "*") |
| 149 | | } |
| 150 | | })) |
| 144 | app.use( |
| 145 | "*", |
| 146 | serveStatic({ |
| 147 | root: "./", |
| 148 | onFound: (_path, c) => { |
| 149 | c.header("Access-Control-Allow-Origin", "*"); |
| 150 | }, |
| 151 | }), |
| 152 | ); |
| 151 | 153 | |
| 152 | | export default app |
| 154 | export default app; |