diff options
| author | nsfisis <nsfisis@gmail.com> | 2023-09-07 22:27:48 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2023-09-07 22:35:53 +0900 |
| commit | 994e0114d76ae19768d5c303874a968cf6369fd0 (patch) | |
| tree | 5fd3f8b169eea00084b24fbae820f75273864d2a /vhosts/blog/nuldoc-src/pages | |
| parent | 57f015992f678bfd7281f171fb9d71349c96a1a0 (diff) | |
| download | nsfisis.dev-994e0114d76ae19768d5c303874a968cf6369fd0.tar.gz nsfisis.dev-994e0114d76ae19768d5c303874a968cf6369fd0.tar.zst nsfisis.dev-994e0114d76ae19768d5c303874a968cf6369fd0.zip | |
meta: migrate to monorepo
Diffstat (limited to 'vhosts/blog/nuldoc-src/pages')
| -rw-r--r-- | vhosts/blog/nuldoc-src/pages/about.ts | 183 | ||||
| -rw-r--r-- | vhosts/blog/nuldoc-src/pages/home.ts | 96 | ||||
| -rw-r--r-- | vhosts/blog/nuldoc-src/pages/not_found.ts | 51 | ||||
| -rw-r--r-- | vhosts/blog/nuldoc-src/pages/post.ts | 140 | ||||
| -rw-r--r-- | vhosts/blog/nuldoc-src/pages/post_list.ts | 64 | ||||
| -rw-r--r-- | vhosts/blog/nuldoc-src/pages/slide.ts | 140 | ||||
| -rw-r--r-- | vhosts/blog/nuldoc-src/pages/slide_list.ts | 65 | ||||
| -rw-r--r-- | vhosts/blog/nuldoc-src/pages/tag.ts | 60 | ||||
| -rw-r--r-- | vhosts/blog/nuldoc-src/pages/tag_list.ts | 76 | ||||
| -rw-r--r-- | vhosts/blog/nuldoc-src/pages/tagged_page.ts | 4 |
10 files changed, 879 insertions, 0 deletions
diff --git a/vhosts/blog/nuldoc-src/pages/about.ts b/vhosts/blog/nuldoc-src/pages/about.ts new file mode 100644 index 00000000..acba113b --- /dev/null +++ b/vhosts/blog/nuldoc-src/pages/about.ts @@ -0,0 +1,183 @@ +import { globalFooter } from "../components/global_footer.ts"; +import { globalHeader } from "../components/global_header.ts"; +import { pageLayout } from "../components/page_layout.ts"; +import { staticScriptElement } from "../components/utils.ts"; +import { Config } from "../config.ts"; +import { el, text } from "../dom.ts"; +import { Page } from "../page.ts"; +import { dateToString } from "../revision.ts"; +import { getPostCreatedDate } from "./post.ts"; +import { SlidePage } from "./slide.ts"; + +export type AboutPage = Page; + +export async function generateAboutPage( + slides: SlidePage[], + config: Config, +): Promise<AboutPage> { + const body = el( + "body", + [["class", "single"]], + globalHeader(config), + el( + "main", + [["class", "main"]], + el( + "article", + [["class", "post-single"]], + el( + "header", + [["class", "post-header"]], + el( + "h1", + [["class", "post-title"]], + text("nsfisis"), + ), + el( + "div", + [["class", "my-icon"]], + await staticScriptElement("/p5.min.js", [], config), + await staticScriptElement("/my-icon.js", [], config), + el("div", [["id", "p5jsMyIcon"]]), + el( + "noscript", + [], + el( + "img", + [["src", "/favicon.svg"]], + ), + ), + ), + ), + el( + "div", + [["class", "post-content"]], + el( + "section", + [], + el( + "h2", + [], + text("読み方"), + ), + el( + "p", + [], + text( + "読み方は決めていません。音にする必要があるときは本名である「いまむら」をお使いください。", + ), + ), + ), + el( + "section", + [], + el( + "h2", + [], + text("アカウント"), + ), + el( + "ul", + [], + el( + "li", + [], + el( + "a", + [["href", "https://twitter.com/nsfisis"]], + text("Twitter (現 𝕏): @nsfisis"), + ), + ), + el( + "li", + [], + el( + "a", + [["href", "https://github.com/nsfisis"]], + text("GitHub: @nsfisis"), + ), + ), + ), + ), + el( + "section", + [], + el( + "h2", + [], + text("仕事"), + ), + el( + "ul", + [], + el( + "li", + [], + text("2021-01~現在: "), + el( + "a", + [["href", "https://www.dgcircus.com/"]], + text("デジタルサーカス株式会社"), + ), + ), + ), + ), + el( + "section", + [], + el( + "h2", + [], + text("登壇"), + ), + el( + "ul", + [], + ...Array.from(slides).sort((a, b) => { + const ta = dateToString(getPostCreatedDate(a)); + const tb = dateToString(getPostCreatedDate(b)); + if (ta > tb) return -1; + if (ta < tb) return 1; + return 0; + }).map((slide) => + el( + "li", + [], + el( + "a", + [["href", slide.href]], + text( + `${ + dateToString(getPostCreatedDate(slide)) + }: ${slide.event} (${slide.talkType})`, + ), + ), + ) + ), + ), + ), + ), + ), + ), + globalFooter(config), + ); + + const html = await pageLayout( + { + metaCopyrightYear: config.blog.siteCopyrightYear, + metaDescription: "このサイトの著者について", + metaKeywords: [], + metaTitle: `About | ${config.blog.siteName}`, + requiresSyntaxHighlight: false, + }, + body, + config, + ); + + return { + root: el("__root__", [], html), + renderer: "html", + destFilePath: "/about/index.html", + href: "/about/", + }; +} diff --git a/vhosts/blog/nuldoc-src/pages/home.ts b/vhosts/blog/nuldoc-src/pages/home.ts new file mode 100644 index 00000000..a240278a --- /dev/null +++ b/vhosts/blog/nuldoc-src/pages/home.ts @@ -0,0 +1,96 @@ +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 HomePage = Page; + +export async function generateHomePage(config: Config): Promise<HomePage> { + const body = el( + "body", + [["class", "single"]], + globalHeader(config), + el( + "main", + [["class", "main"]], + el( + "article", + [["class", "post-single"]], + el( + "article", + [["class", "post-entry"]], + el( + "a", + [["href", "/about/"]], + el( + "header", + [["class", "entry-header"]], + el("h2", [], text("About")), + ), + ), + ), + el( + "article", + [["class", "post-entry"]], + el( + "a", + [["href", "/posts/"]], + el( + "header", + [["class", "entry-header"]], + el("h2", [], text("Posts")), + ), + ), + ), + el( + "article", + [["class", "post-entry"]], + el( + "a", + [["href", "/slides/"]], + el( + "header", + [["class", "entry-header"]], + el("h2", [], text("Slides")), + ), + ), + ), + el( + "article", + [["class", "post-entry"]], + el( + "a", + [["href", "/tags/"]], + el( + "header", + [["class", "entry-header"]], + el("h2", [], text("Tags")), + ), + ), + ), + ), + ), + globalFooter(config), + ); + + const html = await pageLayout( + { + metaCopyrightYear: config.blog.siteCopyrightYear, + metaDescription: "nsfisis のブログサイト", + metaKeywords: [], + metaTitle: config.blog.siteName, + requiresSyntaxHighlight: false, + }, + body, + config, + ); + + return { + root: el("__root__", [], html), + renderer: "html", + destFilePath: "/index.html", + href: "/", + }; +} diff --git a/vhosts/blog/nuldoc-src/pages/not_found.ts b/vhosts/blog/nuldoc-src/pages/not_found.ts new file mode 100644 index 00000000..a1b6109b --- /dev/null +++ b/vhosts/blog/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 | ${config.blog.siteName}`, + requiresSyntaxHighlight: false, + }, + body, + config, + ); + + return { + root: el("__root__", [], html), + renderer: "html", + destFilePath: "/404.html", + href: "/404.html", + }; +} diff --git a/vhosts/blog/nuldoc-src/pages/post.ts b/vhosts/blog/nuldoc-src/pages/post.ts new file mode 100644 index 00000000..24a6d5f5 --- /dev/null +++ b/vhosts/blog/nuldoc-src/pages/post.ts @@ -0,0 +1,140 @@ +import { join } from "std/path/mod.ts"; +import { globalFooter } from "../components/global_footer.ts"; +import { globalHeader } from "../components/global_header.ts"; +import { pageLayout } from "../components/page_layout.ts"; +import { Config, getTagLabel } from "../config.ts"; +import { el, Element, text } from "../dom.ts"; +import { Document } from "../docbook/document.ts"; +import { Page } from "../page.ts"; +import { Date, dateToString, Revision } from "../revision.ts"; + +export interface PostPage extends Page { + title: string; + summary: string; + tags: string[]; + revisions: Revision[]; +} + +export function getPostCreatedDate(page: { revisions: Revision[] }): Date { + return page.revisions[0].date; +} + +export function getPostUpdatedDate(page: { revisions: Revision[] }): Date { + return page.revisions[page.revisions.length - 1].date; +} + +export async function generatePostPage( + doc: Document, + config: Config, +): Promise<PostPage> { + const body = el( + "body", + [["class", "single"]], + globalHeader(config), + el( + "main", + [["class", "main"]], + el( + "article", + [["class", "post-single"]], + el( + "header", + [["class", "post-header"]], + el( + "h1", + [["class", "post-title"]], + text(doc.title), + ), + ...(doc.tags.length === 0 ? [] : [ + el( + "ul", + [["class", "post-tags"]], + ...doc.tags.map((slug) => + el( + "li", + [["class", "tag"]], + el( + "a", + [["href", `/tags/${slug}/`]], + text( + getTagLabel(config, slug), + ), + ), + ) + ), + ), + ]), + ), + el( + "div", + [["class", "post-content"]], + el( + "section", + [], + el( + "h2", + [["id", "changelog"]], + text("更新履歴"), + ), + el( + "ol", + [], + ...doc.revisions.map((rev) => + el( + "li", + [["class", "revision"]], + el( + "time", + [["datetime", dateToString(rev.date)]], + text(dateToString(rev.date)), + ), + text(`: ${rev.remark}`), + ) + ), + ), + ), + // TODO: refactor + ...(doc.root.children[0] as Element).children, + // TODO: footnotes + // <div id="footnotes"> + // <% for footnote in footnotes %> + // <div class="footnote" id="_footnotedef_<%= footnote.index %>"> + // <a href="#_footnoteref_<%= footnote.index %>"><%= footnote.index %></a>. <%= footnote.text %> + // </div> + // <% end %> + // </div> + ), + ), + ), + globalFooter(config), + ); + + const html = await pageLayout( + { + metaCopyrightYear: getPostCreatedDate(doc).year, + metaDescription: doc.summary, + metaKeywords: doc.tags.map((slug) => getTagLabel(config, slug)), + metaTitle: `${doc.title} | ${config.blog.siteName}`, + requiresSyntaxHighlight: true, + }, + body, + config, + ); + + const cwd = Deno.cwd(); + const contentDir = join(cwd, config.locations.contentDir); + const destFilePath = join( + doc.sourceFilePath.replace(contentDir, "").replace(".xml", ""), + "index.html", + ); + return { + root: el("__root__", [], html), + renderer: "html", + destFilePath: destFilePath, + href: destFilePath.replace("index.html", ""), + title: doc.title, + summary: doc.summary, + tags: doc.tags, + revisions: doc.revisions, + }; +} diff --git a/vhosts/blog/nuldoc-src/pages/post_list.ts b/vhosts/blog/nuldoc-src/pages/post_list.ts new file mode 100644 index 00000000..498b3efb --- /dev/null +++ b/vhosts/blog/nuldoc-src/pages/post_list.ts @@ -0,0 +1,64 @@ +import { globalFooter } from "../components/global_footer.ts"; +import { globalHeader } from "../components/global_header.ts"; +import { pageLayout } from "../components/page_layout.ts"; +import { postPageEntry } from "../components/post_page_entry.ts"; +import { Config } from "../config.ts"; +import { el, text } from "../dom.ts"; +import { Page } from "../page.ts"; +import { dateToString } from "../revision.ts"; +import { getPostCreatedDate, PostPage } from "./post.ts"; + +export type PostListPage = Page; + +export async function generatePostListPage( + posts: PostPage[], + config: Config, +): Promise<PostListPage> { + const pageTitle = "投稿一覧"; + + const body = el( + "body", + [["class", "list"]], + globalHeader(config), + el( + "main", + [["class", "main"]], + el( + "header", + [["class", "page-header"]], + el( + "h1", + [], + text(pageTitle), + ), + ), + ...Array.from(posts).sort((a, b) => { + const ta = dateToString(getPostCreatedDate(a)); + const tb = dateToString(getPostCreatedDate(b)); + if (ta > tb) return -1; + if (ta < tb) return 1; + return 0; + }).map((post) => postPageEntry(post)), + ), + globalFooter(config), + ); + + const html = await pageLayout( + { + metaCopyrightYear: config.blog.siteCopyrightYear, + metaDescription: "投稿した記事の一覧", + metaKeywords: [], + metaTitle: `${pageTitle} | ${config.blog.siteName}`, + requiresSyntaxHighlight: false, + }, + body, + config, + ); + + return { + root: el("__root__", [], html), + renderer: "html", + destFilePath: "/posts/index.html", + href: "/posts/", + }; +} diff --git a/vhosts/blog/nuldoc-src/pages/slide.ts b/vhosts/blog/nuldoc-src/pages/slide.ts new file mode 100644 index 00000000..a75aeb68 --- /dev/null +++ b/vhosts/blog/nuldoc-src/pages/slide.ts @@ -0,0 +1,140 @@ +import { join } from "std/path/mod.ts"; +import { globalFooter } from "../components/global_footer.ts"; +import { globalHeader } from "../components/global_header.ts"; +import { pageLayout } from "../components/page_layout.ts"; +import { staticScriptElement } from "../components/utils.ts"; +import { Config, getTagLabel } from "../config.ts"; +import { el, text } from "../dom.ts"; +import { Page } from "../page.ts"; +import { dateToString, Revision } from "../revision.ts"; +import { Slide } from "../slide/slide.ts"; +import { getPostCreatedDate } from "./post.ts"; + +export interface SlidePage extends Page { + title: string; + event: string; + talkType: string; + slideLink: string; + tags: string[]; + revisions: Revision[]; +} + +export async function generateSlidePage( + slide: Slide, + config: Config, +): Promise<SlidePage> { + const body = el( + "body", + [["class", "single"]], + globalHeader(config), + el( + "main", + [["class", "main"]], + el( + "article", + [["class", "post-single"]], + el( + "header", + [["class", "post-header"]], + el( + "h1", + [["class", "post-title"]], + text(slide.title), + ), + ...(slide.tags.length === 0 ? [] : [ + el( + "ul", + [["class", "post-tags"]], + ...slide.tags.map((slug) => + el( + "li", + [["class", "tag"]], + el( + "a", + [["href", `/tags/${slug}/`]], + text( + getTagLabel(config, slug), + ), + ), + ) + ), + ), + ]), + ), + el( + "div", + [["class", "post-content"]], + el( + "section", + [], + el( + "h2", + [["id", "changelog"]], + text("更新履歴"), + ), + el( + "ol", + [], + ...slide.revisions.map((rev) => + el( + "li", + [["class", "revision"]], + el( + "time", + [["datetime", dateToString(rev.date)]], + text(dateToString(rev.date)), + ), + text(`: ${rev.remark}`), + ) + ), + ), + ), + el( + "canvas", + [["id", "slide"], ["data-slide-link", slide.slideLink]], + ), + el( + "div", + [], + el("button", [["id", "prev"]], text("Prev")), + el("button", [["id", "next"]], text("Next")), + ), + await staticScriptElement("/pdf.min.js", [], config), + await staticScriptElement("/slide.js", [["type", "module"]], config), + ), + ), + ), + globalFooter(config), + ); + + const html = await pageLayout( + { + metaCopyrightYear: getPostCreatedDate(slide).year, + metaDescription: slide.title, + metaKeywords: slide.tags.map((slug) => getTagLabel(config, slug)), + metaTitle: `${slide.event} (${slide.talkType}) | ${config.blog.siteName}`, + requiresSyntaxHighlight: true, + }, + body, + config, + ); + + const cwd = Deno.cwd(); + const contentDir = join(cwd, config.locations.contentDir); + const destFilePath = join( + slide.sourceFilePath.replace(contentDir, "").replace(".xml", ""), + "index.html", + ); + return { + root: el("__root__", [], html), + renderer: "html", + destFilePath: destFilePath, + href: destFilePath.replace("index.html", ""), + title: slide.title, + event: slide.event, + talkType: slide.talkType, + slideLink: slide.slideLink, + tags: slide.tags, + revisions: slide.revisions, + }; +} diff --git a/vhosts/blog/nuldoc-src/pages/slide_list.ts b/vhosts/blog/nuldoc-src/pages/slide_list.ts new file mode 100644 index 00000000..5031436d --- /dev/null +++ b/vhosts/blog/nuldoc-src/pages/slide_list.ts @@ -0,0 +1,65 @@ +import { globalFooter } from "../components/global_footer.ts"; +import { globalHeader } from "../components/global_header.ts"; +import { pageLayout } from "../components/page_layout.ts"; +import { slidePageEntry } from "../components/slide_page_entry.ts"; +import { Config } from "../config.ts"; +import { el, text } from "../dom.ts"; +import { Page } from "../page.ts"; +import { dateToString } from "../revision.ts"; +import { getPostCreatedDate } from "./post.ts"; +import { SlidePage } from "./slide.ts"; + +export type SlideListPage = Page; + +export async function generateSlideListPage( + slides: SlidePage[], + config: Config, +): Promise<SlideListPage> { + const pageTitle = "スライド一覧"; + + const body = el( + "body", + [["class", "list"]], + globalHeader(config), + el( + "main", + [["class", "main"]], + el( + "header", + [["class", "page-header"]], + el( + "h1", + [], + text(pageTitle), + ), + ), + ...Array.from(slides).sort((a, b) => { + const ta = dateToString(getPostCreatedDate(a)); + const tb = dateToString(getPostCreatedDate(b)); + if (ta > tb) return -1; + if (ta < tb) return 1; + return 0; + }).map((slide) => slidePageEntry(slide)), + ), + globalFooter(config), + ); + + const html = await pageLayout( + { + metaCopyrightYear: config.blog.siteCopyrightYear, + metaDescription: "登壇したイベントで使用したスライドの一覧", + metaKeywords: [], + metaTitle: `${pageTitle} | ${config.blog.siteName}`, + requiresSyntaxHighlight: false, + }, + body, + config, + ); + + return { + root: el("__root__", [], html), + renderer: "html", + destFilePath: "/slides/index.html", + href: "/slides/", + }; +} diff --git a/vhosts/blog/nuldoc-src/pages/tag.ts b/vhosts/blog/nuldoc-src/pages/tag.ts new file mode 100644 index 00000000..f501cb33 --- /dev/null +++ b/vhosts/blog/nuldoc-src/pages/tag.ts @@ -0,0 +1,60 @@ +import { globalFooter } from "../components/global_footer.ts"; +import { globalHeader } from "../components/global_header.ts"; +import { pageLayout } from "../components/page_layout.ts"; +import { postPageEntry } from "../components/post_page_entry.ts"; +import { slidePageEntry } from "../components/slide_page_entry.ts"; +import { Config, getTagLabel } from "../config.ts"; +import { el, text } from "../dom.ts"; +import { Page } from "../page.ts"; +import { getPostCreatedDate } from "./post.ts"; +import { TaggedPage } from "./tagged_page.ts"; + +export interface TagPage extends Page { + tagSlug: string; + tagLabel: string; +} + +export async function generateTagPage( + tagSlug: string, + pages: TaggedPage[], + config: Config, +): Promise<TagPage> { + const tagLabel = getTagLabel(config, tagSlug); + const pageTitle = `タグ「${tagLabel}」一覧`; + + const body = el( + "body", + [["class", "list"]], + globalHeader(config), + el( + "main", + [["class", "main"]], + el("header", [["class", "page-header"]], el("h1", [], text(pageTitle))), + ...pages.map((page) => + "event" in page ? slidePageEntry(page) : postPageEntry(page) + ), + ), + globalFooter(config), + ); + + const html = await pageLayout( + { + metaCopyrightYear: getPostCreatedDate(pages[pages.length - 1]).year, + metaDescription: `タグ「${tagLabel}」のついた記事またはスライドの一覧`, + metaKeywords: [tagLabel], + metaTitle: `${pageTitle} | ${config.blog.siteName}`, + requiresSyntaxHighlight: false, + }, + body, + config, + ); + + return { + root: el("__root__", [], html), + renderer: "html", + destFilePath: `/tags/${tagSlug}/index.html`, + href: `/tags/${tagSlug}/`, + tagSlug: tagSlug, + tagLabel: tagLabel, + }; +} diff --git a/vhosts/blog/nuldoc-src/pages/tag_list.ts b/vhosts/blog/nuldoc-src/pages/tag_list.ts new file mode 100644 index 00000000..2b58ff32 --- /dev/null +++ b/vhosts/blog/nuldoc-src/pages/tag_list.ts @@ -0,0 +1,76 @@ +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"; +import { TagPage } from "./tag.ts"; + +export type TagListPage = Page; + +export async function generateTagListPage( + tags: TagPage[], + config: Config, +): Promise<TagListPage> { + const pageTitle = "タグ一覧"; + + const body = el( + "body", + [["class", "list"]], + globalHeader(config), + el( + "main", + [["class", "main"]], + el( + "header", + [["class", "page-header"]], + el( + "h1", + [], + text(pageTitle), + ), + ), + ...Array.from(tags).sort((a, b) => { + const ta = a.tagSlug; + const tb = b.tagSlug; + if (ta < tb) return -1; + if (ta > tb) return 1; + return 0; + }).map((tag) => + el( + "article", + [["class", "post-entry"]], + el( + "a", + [["href", tag.href]], + el( + "header", + [["class", "entry-header"]], + el("h2", [], text(tag.tagLabel)), + ), + ), + ) + ), + ), + globalFooter(config), + ); + + const html = await pageLayout( + { + metaCopyrightYear: config.blog.siteCopyrightYear, + metaDescription: "タグの一覧", + metaKeywords: [], + metaTitle: `${pageTitle} | ${config.blog.siteName}`, + requiresSyntaxHighlight: false, + }, + body, + config, + ); + + return { + root: el("__root__", [], html), + renderer: "html", + destFilePath: "/tags/index.html", + href: "/tags/", + }; +} diff --git a/vhosts/blog/nuldoc-src/pages/tagged_page.ts b/vhosts/blog/nuldoc-src/pages/tagged_page.ts new file mode 100644 index 00000000..23de8cb4 --- /dev/null +++ b/vhosts/blog/nuldoc-src/pages/tagged_page.ts @@ -0,0 +1,4 @@ +import { PostPage } from "./post.ts"; +import { SlidePage } from "./slide.ts"; + +export type TaggedPage = PostPage | SlidePage; |
