blog/lib/views/layout.tsx

36 lines
1.0 KiB
TypeScript
Raw Normal View History

2024-06-27 04:22:58 +00:00
import { SITE_DEFAULT_META, SITE_TITLE } from "../constants.ts";
import { JSX } from "preact/jsx-runtime";
2024-06-27 04:22:58 +00:00
import { asset } from "../assets.ts";
type Props = {
title?: string;
meta?: { [name: string]: string };
2024-06-24 17:34:33 +00:00
Content: () => JSX.Element;
};
2024-06-24 17:34:33 +00:00
export default ({ title, meta, Content }: Props) => {
const metaTags = Object.entries(Object.assign({}, SITE_DEFAULT_META, meta || {})).map(
2024-06-28 02:11:30 +00:00
([name, content]) => <meta name={name} content={content} />,
);
return (
<html lang="en">
<head>
<meta charset="utf-8" />
<title
dangerouslySetInnerHTML={{
2024-06-24 17:34:33 +00:00
__html: [title, SITE_TITLE].filter(Boolean).join(" &ndash; "),
}}
/>
{metaTags}
2024-06-24 17:31:11 +00:00
<link rel="stylesheet" type="text/css" href={asset("index.css")} />
</head>
<body>
2024-06-24 17:34:33 +00:00
<div class="main">
<Content />
</div>
</body>
</html>
);
};