blog/src/layout.tsx

36 lines
1.0 KiB
TypeScript
Raw Normal View History

import { SITE_DEFAULT_META, SITE_TITLE } from "./constants.js";
import { JSX } from "preact/jsx-runtime";
2024-06-24 17:31:11 +00:00
import { asset } from "../lib/assets.js";
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(
([name, value]) => <meta name={name} value={value} />,
);
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>
);
};