aboutsummaryrefslogtreecommitdiffhomepage
path: root/nuldoc-src/commands
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2023-03-18 21:27:42 +0900
committernsfisis <nsfisis@gmail.com>2023-03-18 21:27:42 +0900
commit2ee549f5f3b1a05f2a769a4e0daa5507997a3159 (patch)
treed4334a3f0e4a0127b133ed5e5fa9cab94d869b67 /nuldoc-src/commands
parent189a8d8f381dae4e1713a3cbfa651101ceca6034 (diff)
downloadblog.nsfisis.dev-2ee549f5f3b1a05f2a769a4e0daa5507997a3159.tar.gz
blog.nsfisis.dev-2ee549f5f3b1a05f2a769a4e0daa5507997a3159.tar.zst
blog.nsfisis.dev-2ee549f5f3b1a05f2a769a4e0daa5507997a3159.zip
feat(nuldoc): include slides in tag pages
Diffstat (limited to 'nuldoc-src/commands')
-rw-r--r--nuldoc-src/commands/build.ts30
1 files changed, 16 insertions, 14 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;