aboutsummaryrefslogtreecommitdiffhomepage
path: root/services/nuldoc/nuldoc-src/generators
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-02-01 02:28:10 +0900
committernsfisis <nsfisis@gmail.com>2026-02-01 02:28:10 +0900
commitcd16ed5d6b46d91ae9ac7b2237d6405ad6715a4a (patch)
tree0e00d7caf3031fa86decaa0cbc226cc1e521b914 /services/nuldoc/nuldoc-src/generators
parentd08e3edb65b215152aa26e3518fb2f2cd7071c4b (diff)
parent1964f77d03eb647dcf46d63dde68d7ae7301604f (diff)
downloadnsfisis.dev-cd16ed5d6b46d91ae9ac7b2237d6405ad6715a4a.tar.gz
nsfisis.dev-cd16ed5d6b46d91ae9ac7b2237d6405ad6715a4a.tar.zst
nsfisis.dev-cd16ed5d6b46d91ae9ac7b2237d6405ad6715a4a.zip
Merge branch 'feat/ruby-rewrite'
Diffstat (limited to 'services/nuldoc/nuldoc-src/generators')
-rw-r--r--services/nuldoc/nuldoc-src/generators/about.ts21
-rw-r--r--services/nuldoc/nuldoc-src/generators/atom.ts84
-rw-r--r--services/nuldoc/nuldoc-src/generators/home.ts17
-rw-r--r--services/nuldoc/nuldoc-src/generators/not_found.ts20
-rw-r--r--services/nuldoc/nuldoc-src/generators/post.ts63
-rw-r--r--services/nuldoc/nuldoc-src/generators/post_list.ts56
-rw-r--r--services/nuldoc/nuldoc-src/generators/slide.ts51
-rw-r--r--services/nuldoc/nuldoc-src/generators/slide_list.ts21
-rw-r--r--services/nuldoc/nuldoc-src/generators/tag.ts32
-rw-r--r--services/nuldoc/nuldoc-src/generators/tag_list.ts22
-rw-r--r--services/nuldoc/nuldoc-src/generators/tagged_page.ts4
11 files changed, 0 insertions, 391 deletions
diff --git a/services/nuldoc/nuldoc-src/generators/about.ts b/services/nuldoc/nuldoc-src/generators/about.ts
deleted file mode 100644
index 628c370e..00000000
--- a/services/nuldoc/nuldoc-src/generators/about.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import AboutPage from "../pages/AboutPage.ts";
-import { Config } from "../config.ts";
-import { Page } from "../page.ts";
-import { SlidePage } from "./slide.ts";
-
-export type AboutPage = Page;
-
-export async function generateAboutPage(
- slides: SlidePage[],
- config: Config,
-): Promise<AboutPage> {
- const html = await AboutPage(slides, config);
-
- return {
- root: html,
- renderer: "html",
- site: "about",
- destFilePath: "/index.html",
- href: "/",
- };
-}
diff --git a/services/nuldoc/nuldoc-src/generators/atom.ts b/services/nuldoc/nuldoc-src/generators/atom.ts
deleted file mode 100644
index f501d834..00000000
--- a/services/nuldoc/nuldoc-src/generators/atom.ts
+++ /dev/null
@@ -1,84 +0,0 @@
-import { Config } from "../config.ts";
-import { Page } from "../page.ts";
-import { PostPage } from "../generators/post.ts";
-import { SlidePage } from "../generators/slide.ts";
-import { dateToRfc3339String } from "../revision.ts";
-import AtomPage from "../pages/AtomPage.ts";
-
-export type Feed = {
- author: string;
- icon: string;
- id: string;
- linkToSelf: string;
- linkToAlternate: string;
- title: string;
- updated: string;
- entries: Entry[];
-};
-
-export type Entry = {
- id: string;
- linkToAlternate: string;
- published: string;
- summary: string;
- title: string;
- updated: string;
-};
-
-const BASE_NAME = "atom.xml";
-
-export function generateFeedPageFromEntries(
- alternateLink: string,
- feedSlug: string,
- feedTitle: string,
- entries: Array<PostPage | SlidePage>,
- site: "default" | "blog" | "slides",
- config: Config,
-): Page {
- const entries_: Entry[] = [];
- for (const entry of entries) {
- entries_.push({
- id: `urn:uuid:${entry.uuid}`,
- linkToAlternate: `https://${
- "event" in entry ? config.sites.slides.fqdn : config.sites.blog.fqdn
- }${entry.href}`,
- title: entry.title,
- summary: entry.description,
- published: dateToRfc3339String(entry.published),
- updated: dateToRfc3339String(entry.updated),
- });
- }
- // Sort by published date in ascending order.
- entries_.sort((a, b) => {
- if (a.published < b.published) {
- return 1;
- } else if (a.published > b.published) {
- return -1;
- }
- return 0;
- });
- const feedPath = `${alternateLink}${BASE_NAME}`;
- const feed: Feed = {
- author: config.site.author,
- icon: `https://${config.sites[site].fqdn}/favicon.svg`,
- id: `tag:${
- config.sites[site].fqdn
- },${config.site.copyrightYear}:${feedSlug}`,
- linkToSelf: `https://${config.sites[site].fqdn}${feedPath}`,
- linkToAlternate: `https://${config.sites[site].fqdn}${alternateLink}`,
- title: feedTitle,
- updated: entries_.reduce(
- (latest, entry) => entry.updated > latest ? entry.updated : latest,
- entries_[0].updated,
- ),
- entries: entries_,
- };
-
- return {
- root: AtomPage({ feed: feed }),
- renderer: "xml",
- site,
- destFilePath: feedPath,
- href: feedPath,
- };
-}
diff --git a/services/nuldoc/nuldoc-src/generators/home.ts b/services/nuldoc/nuldoc-src/generators/home.ts
deleted file mode 100644
index 1839f5dd..00000000
--- a/services/nuldoc/nuldoc-src/generators/home.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import HomePage from "../pages/HomePage.ts";
-import { Config } from "../config.ts";
-import { Page } from "../page.ts";
-
-export type HomePage = Page;
-
-export async function generateHomePage(config: Config): Promise<HomePage> {
- const html = await HomePage(config);
-
- return {
- root: html,
- renderer: "html",
- site: "default",
- destFilePath: "/index.html",
- href: "/",
- };
-}
diff --git a/services/nuldoc/nuldoc-src/generators/not_found.ts b/services/nuldoc/nuldoc-src/generators/not_found.ts
deleted file mode 100644
index 8a5593c3..00000000
--- a/services/nuldoc/nuldoc-src/generators/not_found.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import NotFoundPage from "../pages/NotFoundPage.ts";
-import { Config } from "../config.ts";
-import { Page } from "../page.ts";
-
-export type NotFoundPage = Page;
-
-export async function generateNotFoundPage(
- site: "default" | "about" | "blog" | "slides",
- config: Config,
-): Promise<NotFoundPage> {
- const html = await NotFoundPage(site, config);
-
- return {
- root: html,
- renderer: "html",
- site,
- destFilePath: "/404.html",
- href: "/404.html",
- };
-}
diff --git a/services/nuldoc/nuldoc-src/generators/post.ts b/services/nuldoc/nuldoc-src/generators/post.ts
deleted file mode 100644
index 87205624..00000000
--- a/services/nuldoc/nuldoc-src/generators/post.ts
+++ /dev/null
@@ -1,63 +0,0 @@
-import { join } from "@std/path";
-import PostPage from "../pages/PostPage.ts";
-import { Config } from "../config.ts";
-import { Document } from "../markdown/document.ts";
-import { Page } from "../page.ts";
-import { Date, Revision } from "../revision.ts";
-
-export interface PostPage extends Page {
- title: string;
- description: string;
- tags: string[];
- revisions: Revision[];
- published: Date;
- updated: Date;
- uuid: string;
- sourceFilePath: string;
-}
-
-export function getPostPublishedDate(page: { revisions: Revision[] }): Date {
- for (const rev of page.revisions) {
- if (!rev.isInternal) {
- return rev.date;
- }
- }
- return page.revisions[0].date;
-}
-
-export function getPostUpdatedDate(page: { revisions: Revision[] }): Date {
- return page.revisions[page.revisions.length - 1].date;
-}
-
-export function postHasAnyUpdates(page: { revisions: Revision[] }): boolean {
- return 2 <= page.revisions.filter((rev) => !rev.isInternal).length;
-}
-
-export async function generatePostPage(
- doc: Document,
- config: Config,
-): Promise<PostPage> {
- const html = await PostPage(doc, config);
-
- const cwd = Deno.cwd();
- const contentDir = join(cwd, config.locations.contentDir);
- const destFilePath = join(
- doc.sourceFilePath.replace(contentDir, "").replace(".md", ""),
- "index.html",
- );
- return {
- root: html,
- renderer: "html",
- site: "blog",
- destFilePath: destFilePath,
- href: destFilePath.replace("index.html", ""),
- title: doc.title,
- description: doc.description,
- tags: doc.tags,
- revisions: doc.revisions,
- published: getPostPublishedDate(doc),
- updated: getPostUpdatedDate(doc),
- uuid: doc.uuid,
- sourceFilePath: doc.sourceFilePath,
- };
-}
diff --git a/services/nuldoc/nuldoc-src/generators/post_list.ts b/services/nuldoc/nuldoc-src/generators/post_list.ts
deleted file mode 100644
index 3be4ec05..00000000
--- a/services/nuldoc/nuldoc-src/generators/post_list.ts
+++ /dev/null
@@ -1,56 +0,0 @@
-import PostListPage from "../pages/PostListPage.ts";
-import { Config } from "../config.ts";
-import { Page } from "../page.ts";
-import { PostPage } from "./post.ts";
-
-export type PostListPage = Page;
-
-export async function generatePostListPages(
- posts: PostPage[],
- config: Config,
-): Promise<PostListPage[]> {
- const postsPerPage = config.sites.blog.postsPerPage;
- const totalPages = Math.ceil(posts.length / postsPerPage);
- const pages: PostListPage[] = [];
-
- for (let pageIndex = 0; pageIndex < totalPages; pageIndex++) {
- const pagePosts = posts.slice(
- pageIndex * postsPerPage,
- (pageIndex + 1) * postsPerPage,
- );
-
- const page = await generatePostListPage(
- pagePosts,
- config,
- pageIndex + 1,
- totalPages,
- );
-
- pages.push(page);
- }
-
- return pages;
-}
-
-async function generatePostListPage(
- posts: PostPage[],
- config: Config,
- currentPage: number,
- totalPages: number,
-): Promise<PostListPage> {
- const html = await PostListPage(posts, config, currentPage, totalPages);
-
- const destFilePath = currentPage === 1
- ? "/posts/index.html"
- : `/posts/${currentPage}/index.html`;
-
- const href = currentPage === 1 ? "/posts/" : `/posts/${currentPage}/`;
-
- return {
- root: html,
- renderer: "html",
- site: "blog",
- destFilePath,
- href,
- };
-}
diff --git a/services/nuldoc/nuldoc-src/generators/slide.ts b/services/nuldoc/nuldoc-src/generators/slide.ts
deleted file mode 100644
index c13f6960..00000000
--- a/services/nuldoc/nuldoc-src/generators/slide.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-import { join } from "@std/path";
-import SlidePage from "../pages/SlidePage.ts";
-import { Config } from "../config.ts";
-import { Page } from "../page.ts";
-import { Date, Revision } from "../revision.ts";
-import { Slide } from "../slide/slide.ts";
-import { getPostPublishedDate, getPostUpdatedDate } from "./post.ts";
-
-export interface SlidePage extends Page {
- title: string;
- description: string;
- event: string;
- talkType: string;
- slideLink: string;
- tags: string[];
- revisions: Revision[];
- published: Date;
- updated: Date;
- uuid: string;
-}
-
-export async function generateSlidePage(
- slide: Slide,
- config: Config,
-): Promise<SlidePage> {
- const html = await SlidePage(slide, config);
-
- const cwd = Deno.cwd();
- const contentDir = join(cwd, config.locations.contentDir);
- const destFilePath = join(
- slide.sourceFilePath.replace(contentDir, "").replace(".toml", ""),
- "index.html",
- );
- return {
- root: html,
- renderer: "html",
- site: "slides",
- destFilePath: destFilePath,
- href: destFilePath.replace("index.html", ""),
- title: slide.title,
- description: `${slide.event} (${slide.talkType})`,
- event: slide.event,
- talkType: slide.talkType,
- slideLink: slide.slideLink,
- tags: slide.tags,
- revisions: slide.revisions,
- published: getPostPublishedDate(slide),
- updated: getPostUpdatedDate(slide),
- uuid: slide.uuid,
- };
-}
diff --git a/services/nuldoc/nuldoc-src/generators/slide_list.ts b/services/nuldoc/nuldoc-src/generators/slide_list.ts
deleted file mode 100644
index b65c9db5..00000000
--- a/services/nuldoc/nuldoc-src/generators/slide_list.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import SlideListPage from "../pages/SlideListPage.ts";
-import { Config } from "../config.ts";
-import { Page } from "../page.ts";
-import { SlidePage } from "./slide.ts";
-
-export type SlideListPage = Page;
-
-export async function generateSlideListPage(
- slides: SlidePage[],
- config: Config,
-): Promise<SlideListPage> {
- const html = await SlideListPage(slides, config);
-
- return {
- root: html,
- renderer: "html",
- site: "slides",
- destFilePath: "/slides/index.html",
- href: "/slides/",
- };
-}
diff --git a/services/nuldoc/nuldoc-src/generators/tag.ts b/services/nuldoc/nuldoc-src/generators/tag.ts
deleted file mode 100644
index efe2da54..00000000
--- a/services/nuldoc/nuldoc-src/generators/tag.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-import TagPage from "../pages/TagPage.ts";
-import { Config, getTagLabel } from "../config.ts";
-import { Page } from "../page.ts";
-import { TaggedPage } from "./tagged_page.ts";
-
-export interface TagPage extends Page {
- tagSlug: string;
- tagLabel: string;
- numOfPosts: number;
- numOfSlides: number;
-}
-
-export async function generateTagPage(
- tagSlug: string,
- pages: TaggedPage[],
- site: "blog" | "slides",
- config: Config,
-): Promise<TagPage> {
- const html = await TagPage(tagSlug, pages, site, config);
-
- return {
- root: html,
- renderer: "html",
- site,
- destFilePath: `/tags/${tagSlug}/index.html`,
- href: `/tags/${tagSlug}/`,
- tagSlug: tagSlug,
- tagLabel: getTagLabel(config, tagSlug),
- numOfPosts: pages.filter((p) => !("event" in p)).length,
- numOfSlides: pages.filter((p) => "event" in p).length,
- };
-}
diff --git a/services/nuldoc/nuldoc-src/generators/tag_list.ts b/services/nuldoc/nuldoc-src/generators/tag_list.ts
deleted file mode 100644
index 96faa663..00000000
--- a/services/nuldoc/nuldoc-src/generators/tag_list.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import TagListPage from "../pages/TagListPage.ts";
-import { Config } from "../config.ts";
-import { Page } from "../page.ts";
-import { TagPage } from "./tag.ts";
-
-export type TagListPage = Page;
-
-export async function generateTagListPage(
- tags: TagPage[],
- site: "blog" | "slides",
- config: Config,
-): Promise<TagListPage> {
- const html = await TagListPage(tags, site, config);
-
- return {
- root: html,
- renderer: "html",
- site,
- destFilePath: "/tags/index.html",
- href: "/tags/",
- };
-}
diff --git a/services/nuldoc/nuldoc-src/generators/tagged_page.ts b/services/nuldoc/nuldoc-src/generators/tagged_page.ts
deleted file mode 100644
index 23de8cb4..00000000
--- a/services/nuldoc/nuldoc-src/generators/tagged_page.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { PostPage } from "./post.ts";
-import { SlidePage } from "./slide.ts";
-
-export type TaggedPage = PostPage | SlidePage;