Skip to content

Commit

Permalink
fix: Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
attakei committed Nov 22, 2024
1 parent a6ce4bc commit 28231b9
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions src/html.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
* This module is to manage routes for Web API (not render html and images).
*/
import { Hono } from 'hono';
import { html, raw } from 'hono/html';
import { Octokit } from '@octokit/rest';
import { fetchContent } from './client';
import { Input } from './components';
import { parseSlug } from './models';
import type { ZennContent } from './models';
import { parseContentMarkdown } from './parser';

const app = new Hono();
const app = new Hono<{ Bindings: CloudflareBindings }>();
app.use(async (c, next) => {
c.setRenderer((content) => {
return c.html(`<!DOCTYPE html>${content}`);
Expand Down Expand Up @@ -103,9 +102,7 @@ app.get('/:slug', async (c) => {
try {
const md = await fetchContent(octokit, addr);
props = parseContentMarkdown(md);
return c.html(
html`
<!DOCTYPE html>
return c.render(
<html lang="ja">
<head>
<meta charset="UTF-8" />
Expand All @@ -116,19 +113,18 @@ app.get('/:slug', async (c) => {
/>
</head>
<body>
<div>
<h1>
${props.frontMatter?.title}
<br />
${props.frontMatter?.emoji}
</h1>
</div>
<hr />
<hr />
<div class="znc">${raw(props.body)}</div>
<div>
<h1>
{props.frontMatter?.title}
<br />
{props.frontMatter?.emoji}
</h1>
</div>
<hr />
<hr />
<div class="znc" dangerouslySetInnerHTML={{ __html: props.body }} />
</body>
</html>
`,
</html>,
);
} catch (error) {
console.error(error);
Expand Down

0 comments on commit 28231b9

Please sign in to comment.