diff options
| -rw-r--r-- | nuldoc-src/command.ts | 15 | ||||
| -rw-r--r-- | nuldoc-src/templates/about.ts | 123 | ||||
| -rw-r--r-- | public/about/index.html | 46 |
3 files changed, 184 insertions, 0 deletions
diff --git a/nuldoc-src/command.ts b/nuldoc-src/command.ts index 70532d4..57e4820 100644 --- a/nuldoc-src/command.ts +++ b/nuldoc-src/command.ts @@ -10,6 +10,7 @@ import { Document } from "./docbook/document.ts"; import convertPost from "./templates/post.ts"; import convertPostList from "./templates/post_list.ts"; import convertTag from "./templates/tag.ts"; +import generateAbout from "./templates/about.ts"; export async function run(command: string, config: Config) { if (command === "build") { @@ -25,6 +26,7 @@ async function cmdBuild(config: Config) { const posts = await generatePosts(config); await generateTags(posts, config); await generatePostList(posts, config); + await generateAboutPage(config); await copyStaticFiles(config); } @@ -110,6 +112,19 @@ async function outputPostList(postList: Document, config: Config) { await writeHtmlFile(postList, destFilePath); } +async function generateAboutPage(config: Config) { + const aboutDoc = await generateAbout(config); + await outputAboutPage(aboutDoc, config); +} + +async function outputAboutPage(about: Document, config: Config) { + const cwd = Deno.cwd(); + const destDir = join(cwd, config.locations.destDir); + const destFilePath = join(destDir, "about", "index.html"); + await ensureDir(dirname(destFilePath)); + await writeHtmlFile(about, destFilePath); +} + async function generateTags(posts: Document[], config: Config) { const tagsAndPosts = collectTags(posts); const tagDocs = await buildTagDocs(tagsAndPosts, config); diff --git a/nuldoc-src/templates/about.ts b/nuldoc-src/templates/about.ts new file mode 100644 index 0000000..c41418c --- /dev/null +++ b/nuldoc-src/templates/about.ts @@ -0,0 +1,123 @@ +import { Element } from "../dom.ts"; +import { Document } from "../docbook/document.ts"; +import { Config } from "../config.ts"; +import { el, stylesheetLinkElement, text } from "./utils.ts"; + +function metaElement(attrs: [string, string][]): Element { + return el("meta", attrs); +} + +function linkElement(rel: string, href: string, type: string | null): Element { + const attrs: [string, string][] = [["rel", rel], ["href", href]]; + if (type !== null) { + attrs.push(["type", type]); + } + return el("link", attrs); +} + +export default async function generateAbout( + config: Config, +): Promise<Document> { + const head = el( + "head", + [], + metaElement([["charset", "UTF-8"]]), + metaElement([["name", "viewport"], [ + "content", + "width=device-width, initial-scale=1.0", + ]]), + metaElement([["name", "author"], ["content", config.blog.author]]), + metaElement([["name", "copyright"], [ + "content", + `© ${config.blog.siteCopyrightYear} ${config.blog.author}`, + ]]), + metaElement([["name", "description"], [ + "content", + "このサイトの著者について", + ]]), + linkElement("icon", "/favicon.svg", "image/svg+xml"), + el("title", [], text(`About | ${config.blog.siteName}`)), + await stylesheetLinkElement("/style.css", config), + ); + const body = el( + "body", + [["class", "single"]], + el( + "header", + [["class", "header"]], + el( + "nav", + [["class", "nav"]], + el( + "ul", + [], + el( + "li", + [["class", "logo"]], + el("a", [["href", "/"]], text(config.blog.siteName)), + ), + el( + "li", + [], + el("a", [["href", "/about"]], text("About")), + ), + el( + "li", + [], + el("a", [["href", "/posts"]], text("Posts")), + ), + el( + "li", + [], + el("a", [["href", "/slides"]], text("Slides")), + ), + ), + ), + ), + el( + "main", + [["class", "main"]], + el( + "article", + [["class", "post-single"]], + el( + "header", + [["class", "post-header"]], + el( + "h1", + [["class", "post-title"]], + text("About"), + ), + ), + el( + "div", + [["class", "post-content"]], + text("WIP"), + ), + ), + ), + el( + "footer", + [["class", "footer"]], + text( + `© ${config.blog.siteCopyrightYear} ${config.blog.author}`, + ), + ), + ); + const html = el( + "html", + [["lang", "ja-JP"]], + head, + body, + ); + const doc = { + root: el("__root__", [], html), + sourceFilePath: "<about>", + link: "/about/", + title: "About", + summary: "このサイトの著者について", + tags: [], + revisions: [], + }; + return doc; +} diff --git a/public/about/index.html b/public/about/index.html new file mode 100644 index 0000000..337add5 --- /dev/null +++ b/public/about/index.html @@ -0,0 +1,46 @@ +<!DOCTYPE html> +<html lang="ja-JP"> + <head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <meta name="author" content="nsfisis"> + <meta name="copyright" content="© 2021 nsfisis"> + <meta name="description" content="このサイトの著者について"> + <link rel="icon" type="image/svg+xml" href="/favicon.svg"> + <title>About | REPL: Rest-Eat-Program Loop</title> + <link rel="stylesheet" href="/style.css?h=17cf97a767ec5fb6e64967729f40f30a"> + </head> + <body class="single"> + <header class="header"> + <nav class="nav"> + <ul> + <li class="logo"> + <a href="/">REPL: Rest-Eat-Program Loop</a> + </li> + <li> + <a href="/about">About</a> + </li> + <li> + <a href="/posts">Posts</a> + </li> + <li> + <a href="/slides">Slides</a> + </li> + </ul> + </nav> + </header> + <main class="main"> + <article class="post-single"> + <header class="post-header"> + <h1 class="post-title">About</h1> + </header> + <div class="post-content"> + WIP + </div> + </article> + </main> + <footer class="footer"> + © 2021 nsfisis + </footer> + </body> +</html> |
