All checks were successful
/ depoly (push) Successful in 1m22s
* add ~platform/DocumentTitle * add titles for some pages
22 lines
512 B
TypeScript
22 lines
512 B
TypeScript
import { children, createRenderEffect, onCleanup, type JSX } from "solid-js";
|
|
|
|
/**
|
|
* Document title.
|
|
*
|
|
* The `children` must be plain text.
|
|
*/
|
|
export default function (props: { children?: JSX.Element }) {
|
|
let otitle: string | undefined;
|
|
|
|
createRenderEffect(() => (otitle = document.title));
|
|
|
|
const title = children(() => props.children);
|
|
|
|
createRenderEffect(
|
|
() => (document.title = (title.toArray() as string[]).join("")),
|
|
);
|
|
|
|
onCleanup(() => (document.title = otitle!));
|
|
|
|
return <></>;
|
|
}
|