aboutsummaryrefslogtreecommitdiffhomepage
path: root/nuldoc-src/pages/slide_list.ts
blob: 18bea1f1f69028b04b26b9e3fe3dab299e3da1c8 (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
import { globalFooter } from "../components/global_footer.ts";
import { globalHeader } from "../components/global_header.ts";
import { pageLayout } from "../components/page_layout.ts";
import { slidePageEntry } from "../components/slide_page_entry.ts";
import { Config } from "../config.ts";
import { el, text } from "../dom.ts";
import { Page } from "../page.ts";
import { getPostCreatedDate } from "./post.ts";
import { SlidePage } from "./slide.ts";

export type SlideListPage = Page;

export async function generateSlideListPage(
  slides: SlidePage[],
  config: Config,
): Promise<SlideListPage> {
  const pageTitle = "スライド一覧";

  const body = el(
    "body",
    [["class", "list"]],
    globalHeader(config),
    el(
      "main",
      [["class", "main"]],
      el(
        "header",
        [["class", "page-header"]],
        el(
          "h1",
          [],
          text(pageTitle),
        ),
      ),
      ...Array.from(slides).sort((a, b) => {
        const ta = getPostCreatedDate(a);
        const tb = getPostCreatedDate(b);
        if (ta > tb) return -1;
        if (ta < tb) return 1;
        return 0;
      }).map((slide) => slidePageEntry(slide)),
    ),
    globalFooter(config),
  );

  const html = await pageLayout(
    {
      metaCopyrightYear: config.blog.siteCopyrightYear,
      metaDescription: "登壇したイベントで使用したスライドの一覧",
      metaKeywords: [],
      metaTitle: `${pageTitle} | ${config.blog.siteName}`,
      requiresSyntaxHighlight: false,
    },
    body,
    config,
  );

  return {
    root: el("__root__", [], html),
    renderer: "html",
    destFilePath: "/slides/index.html",
    href: "/slides/",
  };
}