aboutsummaryrefslogtreecommitdiffhomepage
path: root/services/nuldoc/nuldoc-src/components/PageLayout.ts
blob: f970c0b6d3512bec35ba98d7af5c02ece7ceed31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { Config } from "../config.ts";
import { elem, Element, link, meta, Node } from "../dom.ts";
import StaticStylesheet from "./StaticStylesheet.ts";

type Props = {
  metaCopyrightYear: number;
  metaDescription: string;
  metaKeywords?: string[];
  metaTitle: string;
  metaAtomFeedHref?: string;
  requiresSyntaxHighlight?: boolean;
  site: "default" | "about" | "blog" | "slides";
  config: Config;
  children: Node;
};

export default async function PageLayout(
  {
    metaCopyrightYear,
    metaDescription,
    metaKeywords,
    metaTitle,
    metaAtomFeedHref,
    requiresSyntaxHighlight: _,
    site,
    config,
    children,
  }: Props,
): Promise<Element> {
  return elem(
    "html",
    { lang: "ja-JP" },
    elem(
      "head",
      {},
      meta({ charset: "UTF-8" }),
      meta({
        name: "viewport",
        content: "width=device-width, initial-scale=1.0",
      }),
      meta({ name: "author", content: config.site.author }),
      meta({
        name: "copyright",
        content: `&copy; ${metaCopyrightYear} ${config.site.author}`,
      }),
      meta({ name: "description", content: metaDescription }),
      metaKeywords && metaKeywords.length !== 0
        ? meta({ name: "keywords", content: metaKeywords.join(",") })
        : null,
      meta({ property: "og:type", content: "article" }),
      meta({ property: "og:title", content: metaTitle }),
      meta({ property: "og:description", content: metaDescription }),
      meta({
        property: "og:site_name",
        content: config.sites[site].siteName,
      }),
      meta({ property: "og:locale", content: "ja_JP" }),
      meta({ name: "Hatena::Bookmark", content: "nocomment" }),
      metaAtomFeedHref
        ? link({
          rel: "alternate",
          href: metaAtomFeedHref,
          type: "application/atom+xml",
        })
        : null,
      link({
        rel: "icon",
        href: "/favicon.svg",
        type: "image/svg+xml",
      }),
      elem("title", {}, metaTitle),
      await StaticStylesheet({ fileName: "/style.css", config }),
    ),
    children,
  );
}