diff options
| author | nsfisis <nsfisis@gmail.com> | 2023-03-17 00:48:07 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2023-03-18 21:02:54 +0900 |
| commit | 5208a0a0f7e5703af37c9adf6d60f6c8ef10b9ee (patch) | |
| tree | e2c3272f21e45acb377e70ce2d1c85811e3ab26b /nuldoc-src/commands/build.ts | |
| parent | 7688362ad3b57b0cdd6f048d1e595f69748fc183 (diff) | |
| download | blog.nsfisis.dev-5208a0a0f7e5703af37c9adf6d60f6c8ef10b9ee.tar.gz blog.nsfisis.dev-5208a0a0f7e5703af37c9adf6d60f6c8ef10b9ee.tar.zst blog.nsfisis.dev-5208a0a0f7e5703af37c9adf6d60f6c8ef10b9ee.zip | |
feat(nuldoc): add /slides/ page
Diffstat (limited to 'nuldoc-src/commands/build.ts')
| -rw-r--r-- | nuldoc-src/commands/build.ts | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/nuldoc-src/commands/build.ts b/nuldoc-src/commands/build.ts index fad5c75..8091938 100644 --- a/nuldoc-src/commands/build.ts +++ b/nuldoc-src/commands/build.ts @@ -14,12 +14,17 @@ import { PostPage, } from "../pages/post.ts"; 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 { generateTagListPage } from "../pages/tag_list.ts"; +import { parseSlideFile } from "../slide/parse.ts"; export async function runBuildCommand(config: Config) { const posts = await buildPostPages(config); await buildPostListPage(posts, config); + const slides = await buildSlidePages(config); + await buildSlideListPage(slides, config); const tags = await buildTagPages(posts, config); await buildTagListPage(tags, config); await buildHomePage(config); @@ -28,7 +33,7 @@ export async function runBuildCommand(config: Config) { await copyStaticFiles(config); } -async function buildPostPages(config: Config) { +async function buildPostPages(config: Config): Promise<PostPage[]> { const sourceDir = join(Deno.cwd(), config.locations.contentDir, "posts"); const postFiles = await collectPostFiles(sourceDir); const posts = await parsePosts(postFiles, config); @@ -65,6 +70,43 @@ async function buildPostListPage(posts: PostPage[], config: Config) { await writePage(postListPage, config); } +async function buildSlidePages(config: Config): Promise<SlidePage[]> { + const sourceDir = join(Deno.cwd(), config.locations.contentDir, "slides"); + const slideFiles = await collectSlideFiles(sourceDir); + const slides = await parseSlides(slideFiles, config); + for (const slide of slides) { + await writePage(slide, config); + } + return slides; +} + +async function collectSlideFiles(sourceDir: string): Promise<string[]> { + const filePaths = []; + const globPattern = joinGlobs([sourceDir, "**", "*.xml"]); + for await (const entry of expandGlob(globPattern)) { + filePaths.push(entry.path); + } + return filePaths; +} + +async function parseSlides( + slideFiles: string[], + config: Config, +): Promise<SlidePage[]> { + const slides = []; + for (const slideFile of slideFiles) { + slides.push( + await generateSlidePage(await parseSlideFile(slideFile, config), config), + ); + } + return slides; +} + +async function buildSlideListPage(slides: SlidePage[], config: Config) { + const slideListPage = await generateSlideListPage(slides, config); + await writePage(slideListPage, config); +} + async function buildHomePage(config: Config) { const homePage = await generateHomePage(config); await writePage(homePage, config); |
