Add site meta to templates.
This commit is contained in:
parent
76066ddae1
commit
f25d9aed56
@ -1,5 +1,5 @@
|
|||||||
export type SiteMeta = {
|
export type SiteMeta = {
|
||||||
description: string,
|
description?: string,
|
||||||
tags: string[],
|
tags?: string[],
|
||||||
author?: string,
|
author?: string,
|
||||||
};
|
};
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { Hono } from 'hono';
|
import { Hono } from 'hono';
|
||||||
|
|
||||||
import { PostPage } from '@blog/templates/Pages/PostPage';
|
import { PostPage } from '@blog/templates/Pages/PostPage';
|
||||||
import { FourOhFour } from '@blog/templates/Pages/FourOhFour';
|
import { FourOhFour } from '@blog/templates/Pages/FourOhFour';
|
||||||
import { readdir } from 'node:fs/promises';
|
import { readdir } from 'node:fs/promises';
|
||||||
import { readPostMarkdown } from '@blog/util/readPostMarkdown';
|
import { SiteMeta } from '@blog/model/SiteMeta';
|
||||||
|
import { readPostMarkdown } from '@blog/util/post-reader';
|
||||||
|
|
||||||
const app = new Hono();
|
const app = new Hono();
|
||||||
|
|
||||||
@ -18,8 +18,14 @@ app.get('/posts/:slug', async (c) => {
|
|||||||
return c.render(<FourOhFour />);
|
return c.render(<FourOhFour />);
|
||||||
}
|
}
|
||||||
|
|
||||||
const post = await readPostMarkdown(__dirname + "/../posts/" + postFile);
|
const post = await readPostMarkdown(postFile);
|
||||||
return c.render(<PostPage post={post} />);
|
const meta = {
|
||||||
|
description: post.meta.description,
|
||||||
|
tags: post.meta.tags,
|
||||||
|
author: "Dave Smith-Hayes"
|
||||||
|
};
|
||||||
|
|
||||||
|
return c.render(<PostPage post={post} />, { meta });
|
||||||
});
|
});
|
||||||
|
|
||||||
export default app;
|
export default app;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { css, Style } from 'hono/css';
|
import { css, Style } from 'hono/css';
|
||||||
import { SiteMeta } from '@blog/model/SiteMeta';
|
import { SiteMeta } from '@blog/model/SiteMeta';
|
||||||
|
import { MetaTags } from '@blog/templates/components/MetaTags';
|
||||||
|
|
||||||
const logoClass = css`
|
const logoClass = css`
|
||||||
font-size: 16pt;
|
font-size: 16pt;
|
||||||
@ -10,6 +11,7 @@ export function Page({ children, meta }: { children: any, meta: SiteMeta }) {
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>davesmithhayes.com</title>
|
<title>davesmithhayes.com</title>
|
||||||
|
<MetaTags meta={meta} />
|
||||||
<Style />
|
<Style />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { Post } from "@blog/templates/Pages";
|
import { Post } from "@blog/model/Post";
|
||||||
|
|
||||||
export function PostPage({ post }: { post: Post }) {
|
export function PostPage({ post }: { post: Post }) {
|
||||||
const html = { __html: post.content };
|
const html = { __html: post.html ?? '' };
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<h1>{post.title}</h1>
|
<h1>{post.meta.title}</h1>
|
||||||
<div dangerouslySetInnerHTML={html} />
|
<div dangerouslySetInnerHTML={html} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -24,11 +24,12 @@ export function Author({ meta }: { meta: SiteMeta }) {
|
|||||||
return (<meta name="author" content={meta.author} />);
|
return (<meta name="author" content={meta.author} />);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function MetaTags(meta: SiteMeta) {
|
export function MetaTags({ meta }: { meta: SiteMeta }) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Description meta={meta} />
|
<Description meta={meta} />
|
||||||
<Tags meta={meta} />
|
<Tags meta={meta} />
|
||||||
|
<Author meta={meta} />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user