aboutsummaryrefslogtreecommitdiffhomepage
path: root/nuldoc-src/pages/slide_list.ts
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2023-03-17 00:48:07 +0900
committernsfisis <nsfisis@gmail.com>2023-03-18 21:02:54 +0900
commit5208a0a0f7e5703af37c9adf6d60f6c8ef10b9ee (patch)
treee2c3272f21e45acb377e70ce2d1c85811e3ab26b /nuldoc-src/pages/slide_list.ts
parent7688362ad3b57b0cdd6f048d1e595f69748fc183 (diff)
downloadblog.nsfisis.dev-5208a0a0f7e5703af37c9adf6d60f6c8ef10b9ee.tar.gz
blog.nsfisis.dev-5208a0a0f7e5703af37c9adf6d60f6c8ef10b9ee.tar.zst
blog.nsfisis.dev-5208a0a0f7e5703af37c9adf6d60f6c8ef10b9ee.zip
feat(nuldoc): add /slides/ page
Diffstat (limited to 'nuldoc-src/pages/slide_list.ts')
-rw-r--r--nuldoc-src/pages/slide_list.ts101
1 files changed, 101 insertions, 0 deletions
diff --git a/nuldoc-src/pages/slide_list.ts b/nuldoc-src/pages/slide_list.ts
new file mode 100644
index 0000000..61a2764
--- /dev/null
+++ b/nuldoc-src/pages/slide_list.ts
@@ -0,0 +1,101 @@
+import { globalFooter } from "../components/global_footer.ts";
+import { globalHeader } from "../components/global_header.ts";
+import { pageLayout } from "../components/page_layout.ts";
+import { Config } from "../config.ts";
+import { el, text } from "../dom.ts";
+import { Page } from "../page.ts";
+import { getPostCreatedDate, getPostUpdatedDate } 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) =>
+ el(
+ "article",
+ [["class", "post-entry"]],
+ el(
+ "a",
+ [["href", slide.href]],
+ el(
+ "header",
+ [["class", "entry-header"]],
+ el("h2", [], text(`${slide.event} (${slide.talkType})`)),
+ ),
+ el(
+ "section",
+ [["class", "entry-content"]],
+ el("p", [], text(slide.title)),
+ ),
+ el(
+ "footer",
+ [["class", "entry-footer"]],
+ text("Posted on "),
+ el(
+ "time",
+ [["datetime", getPostCreatedDate(slide)]],
+ text(getPostCreatedDate(slide)),
+ ),
+ ...(slide.revisions.length > 1
+ ? [
+ text(", updated on "),
+ el("time", [[
+ "datetime",
+ getPostUpdatedDate(slide),
+ ]], text(getPostUpdatedDate(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/",
+ };
+}