diff options
| author | nsfisis <nsfisis@gmail.com> | 2023-03-18 19:12:38 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2023-03-18 19:14:05 +0900 |
| commit | b712e14b622aaa76f8b1a5ccfa7b21c9ba1c6d03 (patch) | |
| tree | 507b5ae2197583fbb8d705d76fd3b23a9cc350ed /nuldoc-src | |
| parent | 4b1b65fb57b59c01a8c5480db44f177e7d6d9752 (diff) | |
| download | blog.nsfisis.dev-b712e14b622aaa76f8b1a5ccfa7b21c9ba1c6d03.tar.gz blog.nsfisis.dev-b712e14b622aaa76f8b1a5ccfa7b21c9ba1c6d03.tar.zst blog.nsfisis.dev-b712e14b622aaa76f8b1a5ccfa7b21c9ba1c6d03.zip | |
fix: 404 page
Diffstat (limited to 'nuldoc-src')
| -rw-r--r-- | nuldoc-src/commands/build.ts | 7 | ||||
| -rw-r--r-- | nuldoc-src/pages/not_found.ts | 51 |
2 files changed, 58 insertions, 0 deletions
diff --git a/nuldoc-src/commands/build.ts b/nuldoc-src/commands/build.ts index ef529e0..d523861 100644 --- a/nuldoc-src/commands/build.ts +++ b/nuldoc-src/commands/build.ts @@ -6,6 +6,7 @@ import { parseDocBookFile } from "../docbook/parse.ts"; import { Page } from "../page.ts"; import { render } from "../render.ts"; import { generateAboutPage } from "../pages/about.ts"; +import { generateNotFoundPage } from "../pages/not_found.ts"; import { generatePostPage, getPostCreatedDate, @@ -19,6 +20,7 @@ export async function runBuildCommand(config: Config) { await buildPostListPage(posts, config); await buildTagPages(posts, config); await buildAboutPage(config); + await buildNotFoundPage(config); await copyStaticFiles(config); } @@ -64,6 +66,11 @@ async function buildAboutPage(config: Config) { await writePage(aboutPage, config); } +async function buildNotFoundPage(config: Config) { + const notFoundPage = await generateNotFoundPage(config); + await writePage(notFoundPage, config); +} + async function buildTagPages(posts: PostPage[], config: Config) { const tagsAndPosts = collectTags(posts); for (const [tag, posts] of tagsAndPosts) { diff --git a/nuldoc-src/pages/not_found.ts b/nuldoc-src/pages/not_found.ts new file mode 100644 index 0000000..65938dd --- /dev/null +++ b/nuldoc-src/pages/not_found.ts @@ -0,0 +1,51 @@ +import { globalFooter } from "../components/global_footer.ts"; +import { globalHeader } from "../components/global_header.ts"; +import { pageLayout } from "../components/page_layout.ts"; +import { Config } from "../config.ts"; +import { el, text } from "../dom.ts"; +import { Page } from "../page.ts"; + +export type NotFoundPage = Page; + +export async function generateNotFoundPage( + config: Config, +): Promise<NotFoundPage> { + const body = el( + "body", + [["class", "single"]], + globalHeader(config), + el( + "main", + [["class", "main"]], + el( + "article", + [], + el( + "div", + [["class", "not-found"]], + text("404"), + ), + ), + ), + globalFooter(config), + ); + + const html = await pageLayout( + { + metaCopyrightYear: config.blog.siteCopyrightYear, + metaDescription: "リクエストされたページが見つかりません。", + metaKeywords: [], + metaTitle: "Page Not Found", + requiresSyntaxHighlight: false, + }, + body, + config, + ); + + return { + root: el("__root__", [], html), + renderer: "html", + destFilePath: "/404.html", + href: "/404.html", + }; +} |
