diff options
| author | nsfisis <nsfisis@gmail.com> | 2023-03-18 19:42:37 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2023-03-18 19:42:37 +0900 |
| commit | 032dc3c5e6d0ef84a9f4ea6be10e19b7f43c53b8 (patch) | |
| tree | 0909d231d62f43f3d2a3b7e1bd9dddf3a7be365e /nuldoc-src/pages | |
| parent | 1301f9d35cec5d24b772518b1daa7ffe15684525 (diff) | |
| download | blog.nsfisis.dev-032dc3c5e6d0ef84a9f4ea6be10e19b7f43c53b8.tar.gz blog.nsfisis.dev-032dc3c5e6d0ef84a9f4ea6be10e19b7f43c53b8.tar.zst blog.nsfisis.dev-032dc3c5e6d0ef84a9f4ea6be10e19b7f43c53b8.zip | |
feat(content): add /tags/ page
Diffstat (limited to 'nuldoc-src/pages')
| -rw-r--r-- | nuldoc-src/pages/tag.ts | 7 | ||||
| -rw-r--r-- | nuldoc-src/pages/tag_list.ts | 76 |
2 files changed, 82 insertions, 1 deletions
diff --git a/nuldoc-src/pages/tag.ts b/nuldoc-src/pages/tag.ts index c9eaf7e..b6f136a 100644 --- a/nuldoc-src/pages/tag.ts +++ b/nuldoc-src/pages/tag.ts @@ -6,7 +6,10 @@ import { el, text } from "../dom.ts"; import { Page } from "../page.ts"; import { getPostCreatedDate, getPostUpdatedDate, PostPage } from "./post.ts"; -export type TagPage = Page; +export interface TagPage extends Page { + tagSlug: string; + tagLabel: string; +} export async function generateTagPage( tagSlug: string, @@ -87,5 +90,7 @@ export async function generateTagPage( renderer: "html", destFilePath: `/tags/${tagSlug}/index.html`, href: `/tags/${tagSlug}/`, + tagSlug: tagSlug, + tagLabel: tagLabel, }; } diff --git a/nuldoc-src/pages/tag_list.ts b/nuldoc-src/pages/tag_list.ts new file mode 100644 index 0000000..e4e53f0 --- /dev/null +++ b/nuldoc-src/pages/tag_list.ts @@ -0,0 +1,76 @@ +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 { TagPage } from "./tag.ts"; + +export type TagListPage = Page; + +export async function generateTagListPage( + tags: TagPage[], + config: Config, +): Promise<TagListPage> { + 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(tags).sort((a, b) => { + const ta = a.tagSlug; + const tb = b.tagSlug; + if (ta > tb) return -1; + if (ta < tb) return 1; + return 0; + }).map((tag) => + el( + "article", + [["class", "post-entry"]], + el( + "a", + [["href", tag.href]], + el( + "header", + [["class", "entry-header"]], + el("h2", [], text(tag.tagLabel)), + ), + ), + ) + ), + ), + globalFooter(config), + ); + + const html = await pageLayout( + { + metaCopyrightYear: config.blog.siteCopyrightYear, + metaDescription: "タグの一覧", + metaKeywords: [], + metaTitle: pageTitle, + requiresSyntaxHighlight: false, + }, + body, + config, + ); + + return { + root: el("__root__", [], html), + renderer: "html", + destFilePath: "/tags/index.html", + href: "/tags/", + }; +} |
