diff options
Diffstat (limited to 'nuldoc-src/commands/build.ts')
| -rw-r--r-- | nuldoc-src/commands/build.ts | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/nuldoc-src/commands/build.ts b/nuldoc-src/commands/build.ts index 8765802..90aaab9 100644 --- a/nuldoc-src/commands/build.ts +++ b/nuldoc-src/commands/build.ts @@ -3,8 +3,9 @@ import { ensureDir } from "std/fs/mod.ts"; import { expandGlob } from "std/fs/expand_glob.ts"; import { Config } from "../config.ts"; import { parseDocBookFile } from "../docbook/parse.ts"; -import { writeHtmlFile } from "../html.ts"; import { Document } from "../docbook/document.ts"; +import { Page } from "../page.ts"; +import { render } from "../render.ts"; import convertPost from "../templates/post.ts"; import convertPostList from "../templates/post_list.ts"; import convertTag from "../templates/tag.ts"; @@ -58,7 +59,7 @@ async function outputPosts(posts: Document[], config: Config) { "index.html", ); await ensureDir(dirname(destFilePath)); - await writeHtmlFile(post, destFilePath); + await writePage(docToPage(post, destFilePath)); } } @@ -79,7 +80,7 @@ async function outputPostList(postList: Document, config: Config) { const destDir = join(cwd, config.locations.destDir); const destFilePath = join(destDir, "posts", "index.html"); await ensureDir(dirname(destFilePath)); - await writeHtmlFile(postList, destFilePath); + await writePage(docToPage(postList, destFilePath)); } async function generateAboutPage(config: Config) { @@ -92,7 +93,7 @@ async function outputAboutPage(about: Document, config: Config) { const destDir = join(cwd, config.locations.destDir); const destFilePath = join(destDir, "about", "index.html"); await ensureDir(dirname(destFilePath)); - await writeHtmlFile(about, destFilePath); + await writePage(docToPage(about, destFilePath)); } async function generateTags(posts: Document[], config: Config) { @@ -153,7 +154,7 @@ async function outputTags(tagDocs: [string, Document][], config: Config) { for (const [tag, tagDoc] of tagDocs) { const destFilePath = join(destDir, "tags", tag, "index.html"); await ensureDir(dirname(destFilePath)); - await writeHtmlFile(tagDoc, destFilePath); + await writePage(docToPage(tagDoc, destFilePath)); } } @@ -168,3 +169,15 @@ async function copyStaticFiles(config: Config) { await Deno.copyFile(src, dst); } } + +async function writePage(page: Page) { + await Deno.writeTextFile(page.destFilePath, render(page.root, page.renderer)); +} + +function docToPage(d: Document, p: string): Page { + return { + root: d.root, + renderer: "html", + destFilePath: p, + }; +} |
