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
|
import GlobalFooter from "../components/GlobalFooter.ts";
import GlobalHeader from "../components/BlogGlobalHeader.ts";
import PageLayout from "../components/PageLayout.ts";
import TableOfContents from "../components/TableOfContents.ts";
import { Config, getTagLabel } from "../config.ts";
import { elem, Element } from "../dom.ts";
import { Document } from "../djot/document.ts";
import { dateToString } from "../revision.ts";
import { getPostPublishedDate } from "../generators/post.ts";
export default async function PostPage(
doc: Document,
config: Config,
): Promise<Element> {
return await PageLayout({
metaCopyrightYear: getPostPublishedDate(doc).year,
metaDescription: doc.description,
metaKeywords: doc.tags.map((slug) => getTagLabel(config, slug)),
metaTitle: `${doc.title}|${config.sites.blog.siteName}`,
requiresSyntaxHighlight: true,
site: "blog",
config,
children: elem(
"body",
{ class: "single" },
GlobalHeader({ config }),
elem(
"main",
{ class: "main" },
elem(
"article",
{ class: "post-single" },
elem(
"header",
{ class: "post-header" },
elem("h1", { class: "post-title" }, doc.title),
doc.tags.length !== 0
? elem(
"ul",
{ class: "post-tags" },
...doc.tags.map((slug) =>
elem(
"li",
{ class: "tag" },
elem(
"a",
{ href: `/tags/${slug}/` },
getTagLabel(config, slug),
),
)
),
)
: null,
),
doc.toc && doc.toc.entries.length > 0
? TableOfContents({ toc: doc.toc })
: null,
elem(
"div",
{ class: "post-content" },
elem(
"section",
{ id: "changelog" },
elem("h2", {}, elem("a", { href: "#changelog" }, "更新履歴")),
elem(
"ol",
{},
...doc.revisions.map((rev) =>
elem(
"li",
{ class: "revision" },
elem(
"time",
{ datetime: dateToString(rev.date) },
dateToString(rev.date),
),
`: ${rev.remark}`,
)
),
),
),
// TODO: refactor
...(doc.root.children[0] as Element).children,
),
),
),
GlobalFooter({ config }),
),
});
}
|