aboutsummaryrefslogtreecommitdiffhomepage
path: root/services/nuldoc/nuldoc-src/pages/SlidePage.ts
blob: 48e803788b71c6e3ed1c28900d7ba903bf8b1fe6 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import GlobalFooter from "../components/GlobalFooter.ts";
import GlobalHeader from "../components/SlidesGlobalHeader.ts";
import PageLayout from "../components/PageLayout.ts";
import StaticScript from "../components/StaticScript.ts";
import { Config, getTagLabel } from "../config.ts";
import { dateToString } from "../revision.ts";
import { Slide } from "../slide/slide.ts";
import { getPostPublishedDate } from "../generators/post.ts";
import {
  a,
  article,
  button,
  div,
  elem,
  Element,
  h1,
  h2,
  header,
  li,
  ol,
  section,
  ul,
} from "../dom.ts";

export default async function SlidePage(
  slide: Slide,
  config: Config,
): Promise<Element> {
  return await PageLayout({
    metaCopyrightYear: getPostPublishedDate(slide).year,
    metaDescription: slide.title,
    metaKeywords: slide.tags.map((slug) => getTagLabel(config, slug)),
    metaTitle:
      `${slide.event} (${slide.talkType})|${config.sites.slides.siteName}`,
    requiresSyntaxHighlight: true,
    site: "slides",
    config,
    children: elem(
      "body",
      { class: "single" },
      GlobalHeader({ config }),
      elem(
        "main",
        { class: "main" },
        article(
          { class: "post-single" },
          header(
            { class: "post-header" },
            h1({ class: "post-title" }, slide.title),
            slide.tags.length !== 0
              ? ul(
                { class: "post-tags" },
                ...slide.tags.map((slug) =>
                  li(
                    { class: "tag" },
                    a(
                      { href: `/tags/${slug}/` },
                      getTagLabel(config, slug),
                    ),
                  )
                ),
              )
              : null,
          ),
          div(
            { class: "post-content" },
            section(
              { id: "changelog" },
              h2({}, a({ href: "#changelog" }, "更新履歴")),
              ol(
                {},
                ...slide.revisions.map((rev) =>
                  li(
                    { class: "revision" },
                    elem(
                      "time",
                      { datetime: dateToString(rev.date) },
                      dateToString(rev.date),
                    ),
                    `: ${rev.remark}`,
                  )
                ),
              ),
            ),
            elem("canvas", { id: "slide", "data-slide-link": slide.slideLink }),
            div(
              {},
              button({ id: "prev", type: "button" }, "Prev"),
              button({ id: "next", type: "button" }, "Next"),
            ),
            await StaticScript({
              site: "slides",
              fileName: "/slide.js",
              type: "module",
              config,
            }),
          ),
        ),
      ),
      GlobalFooter({ config }),
    ),
  });
}