diff options
Diffstat (limited to 'nuldoc-src')
| -rw-r--r-- | nuldoc-src/commands/build.ts | 30 | ||||
| -rw-r--r-- | nuldoc-src/pages/slide_list.ts | 2 | ||||
| -rw-r--r-- | nuldoc-src/pages/tag.ts | 27 | ||||
| -rw-r--r-- | nuldoc-src/pages/tagged_page.ts | 4 |
4 files changed, 35 insertions, 28 deletions
diff --git a/nuldoc-src/commands/build.ts b/nuldoc-src/commands/build.ts index 8091938..8961da9 100644 --- a/nuldoc-src/commands/build.ts +++ b/nuldoc-src/commands/build.ts @@ -17,6 +17,7 @@ import { generatePostListPage } from "../pages/post_list.ts"; import { generateSlidePage, SlidePage } from "../pages/slide.ts"; import { generateSlideListPage } from "../pages/slide_list.ts"; import { generateTagPage, TagPage } from "../pages/tag.ts"; +import { TaggedPage } from "../pages/tagged_page.ts"; import { generateTagListPage } from "../pages/tag_list.ts"; import { parseSlideFile } from "../slide/parse.ts"; @@ -25,7 +26,7 @@ export async function runBuildCommand(config: Config) { await buildPostListPage(posts, config); const slides = await buildSlidePages(config); await buildSlideListPage(slides, config); - const tags = await buildTagPages(posts, config); + const tags = await buildTagPages(posts, slides, config); await buildTagListPage(tags, config); await buildHomePage(config); await buildAboutPage(config); @@ -124,12 +125,13 @@ async function buildNotFoundPage(config: Config) { async function buildTagPages( posts: PostPage[], + slides: SlidePage[], config: Config, ): Promise<TagPage[]> { - const tagsAndPosts = collectTags(posts); + const tagsAndPages = collectTags([...posts, ...slides]); const tags = []; - for (const [tag, posts] of tagsAndPosts) { - const tagPage = await generateTagPage(tag, posts, config); + for (const [tag, pages] of tagsAndPages) { + const tagPage = await generateTagPage(tag, pages, config); await writePage(tagPage, config); tags.push(tagPage); } @@ -141,22 +143,22 @@ async function buildTagListPage(tags: TagPage[], config: Config) { await writePage(tagListPage, config); } -function collectTags(posts: PostPage[]): [string, PostPage[]][] { - const tagsAndPosts = new Map(); - for (const post of posts) { - for (const tag of post.tags) { - if (!tagsAndPosts.has(tag)) { - tagsAndPosts.set(tag, []); +function collectTags(taggedPages: TaggedPage[]): [string, TaggedPage[]][] { + const tagsAndPages = new Map(); + for (const page of taggedPages) { + for (const tag of page.tags) { + if (!tagsAndPages.has(tag)) { + tagsAndPages.set(tag, []); } - tagsAndPosts.get(tag).push(post); + tagsAndPages.get(tag).push(page); } } - const result: [string, PostPage[]][] = []; - for (const tag of Array.from(tagsAndPosts.keys()).sort()) { + const result: [string, TaggedPage[]][] = []; + for (const tag of Array.from(tagsAndPages.keys()).sort()) { result.push([ tag, - tagsAndPosts.get(tag).sort((a: PostPage, b: PostPage) => { + tagsAndPages.get(tag).sort((a: TaggedPage, b: TaggedPage) => { const ta = getPostCreatedDate(a); const tb = getPostCreatedDate(b); if (ta > tb) return -1; diff --git a/nuldoc-src/pages/slide_list.ts b/nuldoc-src/pages/slide_list.ts index 61a2764..fbb5778 100644 --- a/nuldoc-src/pages/slide_list.ts +++ b/nuldoc-src/pages/slide_list.ts @@ -47,7 +47,7 @@ export async function generateSlideListPage( el( "header", [["class", "entry-header"]], - el("h2", [], text(`${slide.event} (${slide.talkType})`)), + el("h2", [], text(`登壇: ${slide.event} (${slide.talkType})`)), ), el( "section", diff --git a/nuldoc-src/pages/tag.ts b/nuldoc-src/pages/tag.ts index c0b6262..dd7a5c0 100644 --- a/nuldoc-src/pages/tag.ts +++ b/nuldoc-src/pages/tag.ts @@ -4,7 +4,8 @@ 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, PostPage } from "./post.ts"; +import { getPostCreatedDate, getPostUpdatedDate } from "./post.ts"; +import { TaggedPage } from "./tagged_page.ts"; export interface TagPage extends Page { tagSlug: string; @@ -13,7 +14,7 @@ export interface TagPage extends Page { export async function generateTagPage( tagSlug: string, - posts: PostPage[], + pages: TaggedPage[], config: Config, ): Promise<TagPage> { const tagLabel = @@ -28,22 +29,22 @@ export async function generateTagPage( "main", [["class", "main"]], el("header", [["class", "page-header"]], el("h1", [], text(pageTitle))), - ...posts.map((post) => + ...pages.map((page) => el( "article", [["class", "post-entry"]], el( "a", - [["href", post.href]], + [["href", page.href]], el( "header", [["class", "entry-header"]], - el("h2", [], text(post.title)), + el("h2", [], text("event" in page ? `登壇: ${page.event} (${page.talkType})` : page.title)), ), el( "section", [["class", "entry-content"]], - el("p", [], text(post.summary)), + el("p", [], text("event" in page ? page.title : page.summary)), ), el( "footer", @@ -51,16 +52,16 @@ export async function generateTagPage( text("Posted on "), el( "time", - [["datetime", getPostCreatedDate(post)]], - text(getPostCreatedDate(post)), + [["datetime", getPostCreatedDate(page)]], + text(getPostCreatedDate(page)), ), - ...(post.revisions.length > 1 + ...(page.revisions.length > 1 ? [ text(", updated on "), el("time", [[ "datetime", - getPostUpdatedDate(post), - ]], text(getPostUpdatedDate(post))), + getPostUpdatedDate(page), + ]], text(getPostUpdatedDate(page))), ] : []), ), @@ -74,9 +75,9 @@ export async function generateTagPage( const html = await pageLayout( { metaCopyrightYear: parseInt( - getPostCreatedDate(posts[posts.length - 1]).substring(0, 4), + getPostCreatedDate(pages[pages.length - 1]).substring(0, 4), ), - metaDescription: `タグ「${tagLabel}」のついた記事一覧`, + metaDescription: `タグ「${tagLabel}」のついた記事またはスライドの一覧`, metaKeywords: [tagLabel], metaTitle: `${pageTitle} | ${config.blog.siteName}`, requiresSyntaxHighlight: false, diff --git a/nuldoc-src/pages/tagged_page.ts b/nuldoc-src/pages/tagged_page.ts new file mode 100644 index 0000000..23de8cb --- /dev/null +++ b/nuldoc-src/pages/tagged_page.ts @@ -0,0 +1,4 @@ +import { PostPage } from "./post.ts"; +import { SlidePage } from "./slide.ts"; + +export type TaggedPage = PostPage | SlidePage; |
