diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-02-22 01:51:21 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-02-24 14:24:15 +0900 |
| commit | 7c81d7bf5bcb6fb9578ae4ae54684742bf9ae35d (patch) | |
| tree | 4534959896de4ba5492f8f35417fd45670296574 /vhosts/blog/nuldoc-src/commands | |
| parent | b72e1bd7b40f1c9c3558b6ed50367a2b7fc11d62 (diff) | |
| download | nsfisis.dev-7c81d7bf5bcb6fb9578ae4ae54684742bf9ae35d.tar.gz nsfisis.dev-7c81d7bf5bcb6fb9578ae4ae54684742bf9ae35d.tar.zst nsfisis.dev-7c81d7bf5bcb6fb9578ae4ae54684742bf9ae35d.zip | |
feat(blog/nuldoc): implement generating Atom feed
Diffstat (limited to 'vhosts/blog/nuldoc-src/commands')
| -rw-r--r-- | vhosts/blog/nuldoc-src/commands/build.ts | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/vhosts/blog/nuldoc-src/commands/build.ts b/vhosts/blog/nuldoc-src/commands/build.ts index 92230d7d..355604d8 100644 --- a/vhosts/blog/nuldoc-src/commands/build.ts +++ b/vhosts/blog/nuldoc-src/commands/build.ts @@ -1,7 +1,8 @@ import { dirname, join, joinGlobs } from "std/path/mod.ts"; import { ensureDir } from "std/fs/mod.ts"; import { expandGlob } from "std/fs/expand_glob.ts"; -import { Config } from "../config.ts"; +import { generateFeedPageFromEntries } from "../atom/generate.ts"; +import { Config, getTagLabel } from "../config.ts"; import { parseNulDocFile } from "../ndoc/parse.ts"; import { Page } from "../page.ts"; import { render } from "../render.ts"; @@ -32,6 +33,7 @@ export async function runBuildCommand(config: Config) { await buildHomePage(config); await buildAboutPage(slides, config); await buildNotFoundPage(config); + await buildFeedOfAllContents(posts, slides, config); await copyStaticFiles(config); await copyAssetFiles(slides, config); } @@ -71,6 +73,14 @@ async function parsePosts( async function buildPostListPage(posts: PostPage[], config: Config) { const postListPage = await generatePostListPage(posts, config); await writePage(postListPage, config); + const postFeedPage = generateFeedPageFromEntries( + postListPage.href, + "posts", + `投稿一覧|${config.blog.siteName}`, + posts, + config, + ); + await writePage(postFeedPage, config); } async function buildSlidePages(config: Config): Promise<SlidePage[]> { @@ -108,6 +118,14 @@ async function parseSlides( async function buildSlideListPage(slides: SlidePage[], config: Config) { const slideListPage = await generateSlideListPage(slides, config); await writePage(slideListPage, config); + const slideFeedPage = generateFeedPageFromEntries( + slideListPage.href, + "slides", + `スライド一覧|${config.blog.siteName}`, + slides, + config, + ); + await writePage(slideFeedPage, config); } async function buildHomePage(config: Config) { @@ -125,6 +143,21 @@ async function buildNotFoundPage(config: Config) { await writePage(notFoundPage, config); } +async function buildFeedOfAllContents( + posts: PostPage[], + slides: SlidePage[], + config: Config, +) { + const feed = generateFeedPageFromEntries( + "/", + "all", + config.blog.siteName, + [...posts, ...slides], + config, + ); + await writePage(feed, config); +} + async function buildTagPages( posts: PostPage[], slides: SlidePage[], @@ -135,6 +168,14 @@ async function buildTagPages( for (const [tag, pages] of tagsAndPages) { const tagPage = await generateTagPage(tag, pages, config); await writePage(tagPage, config); + const tagFeedPage = generateFeedPageFromEntries( + tagPage.href, + `tag-${tag}`, + `タグ「${getTagLabel(config, tag)}」一覧|${config.blog.siteName}`, + pages, + config, + ); + await writePage(tagFeedPage, config); tags.push(tagPage); } return tags; |
