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