This commit is contained in:
Thibault “Adædra” Hamel 2024-06-24 19:34:33 +02:00
parent 73849b7f04
commit 80912cb6e2

View File

@ -5,10 +5,11 @@ import { asset } from "../lib/assets.js";
type Props = {
title?: string;
meta?: { [name: string]: string };
} & ({ content: string } | { Content(): JSX.Element });
Content: () => JSX.Element;
};
export default (props: Props) => {
const metaTags = Object.entries(Object.assign({}, SITE_DEFAULT_META, props.meta || {})).map(
export default ({ title, meta, Content }: Props) => {
const metaTags = Object.entries(Object.assign({}, SITE_DEFAULT_META, meta || {})).map(
([name, value]) => <meta name={name} value={value} />,
);
@ -18,20 +19,16 @@ export default (props: Props) => {
<meta charset="utf-8" />
<title
dangerouslySetInnerHTML={{
__html: [props.title, SITE_TITLE].filter(Boolean).join(" &ndash; "),
__html: [title, SITE_TITLE].filter(Boolean).join(" &ndash; "),
}}
/>
{metaTags}
<link rel="stylesheet" type="text/css" href={asset("index.css")} />
</head>
<body>
{"Content" in props ? (
<div class="main">
<props.Content />
<Content />
</div>
) : (
<div class="main" dangerouslySetInnerHTML={{ __html: props.content }} />
)}
</body>
</html>
);