summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-01-12 21:59:55 +0900
committernsfisis <nsfisis@gmail.com>2025-01-12 22:16:17 +0900
commit16182acfcc1fad2885b9c1a96fe74d8ce56a50e0 (patch)
treedfff5ee9b9a9e16680fda5cba36e5c817eda1f9e
parentf31d24cd1417088b7806ddc7d2e0df982d666e38 (diff)
downloadnsfisis.dev-16182acfcc1fad2885b9c1a96fe74d8ce56a50e0.tar.gz
nsfisis.dev-16182acfcc1fad2885b9c1a96fe74d8ce56a50e0.tar.zst
nsfisis.dev-16182acfcc1fad2885b9c1a96fe74d8ce56a50e0.zip
refactor(blog/nuldoc): separate pages/* to pages/* and generators/*
-rw-r--r--vhosts/blog/nuldoc-src/atom/generate.ts4
-rw-r--r--vhosts/blog/nuldoc-src/commands/build.ts20
-rw-r--r--vhosts/blog/nuldoc-src/components/PostPageEntry.tsx2
-rw-r--r--vhosts/blog/nuldoc-src/components/SlidePageEntry.tsx4
-rw-r--r--vhosts/blog/nuldoc-src/generators/about.ts23
-rw-r--r--vhosts/blog/nuldoc-src/generators/home.ts19
-rw-r--r--vhosts/blog/nuldoc-src/generators/not_found.ts21
-rw-r--r--vhosts/blog/nuldoc-src/generators/post.ts63
-rw-r--r--vhosts/blog/nuldoc-src/generators/post_list.ts23
-rw-r--r--vhosts/blog/nuldoc-src/generators/slide.ts53
-rw-r--r--vhosts/blog/nuldoc-src/generators/slide_list.ts23
-rw-r--r--vhosts/blog/nuldoc-src/generators/tag.ts33
-rw-r--r--vhosts/blog/nuldoc-src/generators/tag_list.ts23
-rw-r--r--vhosts/blog/nuldoc-src/generators/tagged_page.ts4
-rw-r--r--vhosts/blog/nuldoc-src/pages/AboutPage.tsx (renamed from vhosts/blog/nuldoc-src/pages/about.tsx)23
-rw-r--r--vhosts/blog/nuldoc-src/pages/HomePage.tsx (renamed from vhosts/blog/nuldoc-src/pages/home.tsx)17
-rw-r--r--vhosts/blog/nuldoc-src/pages/NotFoundPage.tsx (renamed from vhosts/blog/nuldoc-src/pages/not_found.tsx)19
-rw-r--r--vhosts/blog/nuldoc-src/pages/PostListPage.tsx (renamed from vhosts/blog/nuldoc-src/pages/post_list.tsx)21
-rw-r--r--vhosts/blog/nuldoc-src/pages/PostPage.tsx (renamed from vhosts/blog/nuldoc-src/pages/post.tsx)61
-rw-r--r--vhosts/blog/nuldoc-src/pages/SlideListPage.tsx (renamed from vhosts/blog/nuldoc-src/pages/slide_list.tsx)23
-rw-r--r--vhosts/blog/nuldoc-src/pages/SlidePage.tsx (renamed from vhosts/blog/nuldoc-src/pages/slide.tsx)51
-rw-r--r--vhosts/blog/nuldoc-src/pages/TagListPage.tsx (renamed from vhosts/blog/nuldoc-src/pages/tag_list.tsx)21
-rw-r--r--vhosts/blog/nuldoc-src/pages/TagPage.tsx (renamed from vhosts/blog/nuldoc-src/pages/tag.tsx)32
-rw-r--r--vhosts/blog/nuldoc-src/pages/tagged_page.ts4
24 files changed, 347 insertions, 240 deletions
diff --git a/vhosts/blog/nuldoc-src/atom/generate.ts b/vhosts/blog/nuldoc-src/atom/generate.ts
index 9e30ef3e..3c76f6c5 100644
--- a/vhosts/blog/nuldoc-src/atom/generate.ts
+++ b/vhosts/blog/nuldoc-src/atom/generate.ts
@@ -2,8 +2,8 @@ import { Config } from "../config.ts";
import { el } from "../dom.ts";
import { Page } from "../page.ts";
import { Entry, Feed } from "./types.ts";
-import { PostPage } from "../pages/post.tsx";
-import { SlidePage } from "../pages/slide.tsx";
+import { PostPage } from "../generators/post.ts";
+import { SlidePage } from "../generators/slide.ts";
import { dateToRfc3339String } from "../revision.ts";
const BASE_NAME = "atom.xml";
diff --git a/vhosts/blog/nuldoc-src/commands/build.ts b/vhosts/blog/nuldoc-src/commands/build.ts
index a542b4f8..a596dc2a 100644
--- a/vhosts/blog/nuldoc-src/commands/build.ts
+++ b/vhosts/blog/nuldoc-src/commands/build.ts
@@ -7,20 +7,20 @@ import { parseNulDocFile } from "../ndoc/parse.ts";
import { Page } from "../page.ts";
import { render } from "../render.ts";
import { dateToString } from "../revision.ts";
-import { generateAboutPage } from "../pages/about.tsx";
-import { generateHomePage } from "../pages/home.tsx";
-import { generateNotFoundPage } from "../pages/not_found.tsx";
+import { generateAboutPage } from "../generators/about.ts";
+import { generateHomePage } from "../generators/home.ts";
+import { generateNotFoundPage } from "../generators/not_found.ts";
import {
generatePostPage,
getPostPublishedDate,
PostPage,
-} from "../pages/post.tsx";
-import { generatePostListPage } from "../pages/post_list.tsx";
-import { generateSlidePage, SlidePage } from "../pages/slide.tsx";
-import { generateSlideListPage } from "../pages/slide_list.tsx";
-import { generateTagPage, TagPage } from "../pages/tag.tsx";
-import { TaggedPage } from "../pages/tagged_page.ts";
-import { generateTagListPage } from "../pages/tag_list.tsx";
+} from "../generators/post.ts";
+import { generatePostListPage } from "../generators/post_list.ts";
+import { generateSlidePage, SlidePage } from "../generators/slide.ts";
+import { generateSlideListPage } from "../generators/slide_list.ts";
+import { generateTagPage, TagPage } from "../generators/tag.ts";
+import { TaggedPage } from "../generators/tagged_page.ts";
+import { generateTagListPage } from "../generators/tag_list.ts";
import { parseSlideFile } from "../slide/parse.ts";
export async function runBuildCommand(config: Config) {
diff --git a/vhosts/blog/nuldoc-src/components/PostPageEntry.tsx b/vhosts/blog/nuldoc-src/components/PostPageEntry.tsx
index 52e2b5d4..2708b009 100644
--- a/vhosts/blog/nuldoc-src/components/PostPageEntry.tsx
+++ b/vhosts/blog/nuldoc-src/components/PostPageEntry.tsx
@@ -3,7 +3,7 @@ import {
getPostUpdatedDate,
postHasAnyUpdates,
PostPage,
-} from "../pages/post.tsx";
+} from "../generators/post.ts";
import { dateToString } from "../revision.ts";
export default function PostPageEntry({ post }: { post: PostPage }) {
diff --git a/vhosts/blog/nuldoc-src/components/SlidePageEntry.tsx b/vhosts/blog/nuldoc-src/components/SlidePageEntry.tsx
index 3fa827f9..d2cf9a17 100644
--- a/vhosts/blog/nuldoc-src/components/SlidePageEntry.tsx
+++ b/vhosts/blog/nuldoc-src/components/SlidePageEntry.tsx
@@ -2,8 +2,8 @@ import {
getPostPublishedDate,
getPostUpdatedDate,
postHasAnyUpdates,
-} from "../pages/post.tsx";
-import { SlidePage } from "../pages/slide.tsx";
+} from "../generators/post.ts";
+import { SlidePage } from "../generators/slide.ts";
import { dateToString } from "../revision.ts";
export default function SlidePageEntry({ slide }: { slide: SlidePage }) {
diff --git a/vhosts/blog/nuldoc-src/generators/about.ts b/vhosts/blog/nuldoc-src/generators/about.ts
new file mode 100644
index 00000000..6663a190
--- /dev/null
+++ b/vhosts/blog/nuldoc-src/generators/about.ts
@@ -0,0 +1,23 @@
+import AboutPage from "../pages/AboutPage.tsx";
+import { Config } from "../config.ts";
+import { renderToDOM } from "../jsx/render.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 renderToDOM(
+ AboutPage(slides, config),
+ );
+
+ return {
+ root: html,
+ renderer: "html",
+ destFilePath: "/about/index.html",
+ href: "/about/",
+ };
+}
diff --git a/vhosts/blog/nuldoc-src/generators/home.ts b/vhosts/blog/nuldoc-src/generators/home.ts
new file mode 100644
index 00000000..679dd39a
--- /dev/null
+++ b/vhosts/blog/nuldoc-src/generators/home.ts
@@ -0,0 +1,19 @@
+import HomePage from "../pages/HomePage.tsx";
+import { renderToDOM } from "../jsx/render.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 renderToDOM(
+ HomePage(config),
+ );
+
+ return {
+ root: html,
+ renderer: "html",
+ destFilePath: "/index.html",
+ href: "/",
+ };
+}
diff --git a/vhosts/blog/nuldoc-src/generators/not_found.ts b/vhosts/blog/nuldoc-src/generators/not_found.ts
new file mode 100644
index 00000000..f5a81c86
--- /dev/null
+++ b/vhosts/blog/nuldoc-src/generators/not_found.ts
@@ -0,0 +1,21 @@
+import NotFoundPage from "../pages/NotFoundPage.tsx";
+import { renderToDOM } from "../jsx/render.ts";
+import { Config } from "../config.ts";
+import { Page } from "../page.ts";
+
+export type NotFoundPage = Page;
+
+export async function generateNotFoundPage(
+ config: Config,
+): Promise<NotFoundPage> {
+ const html = await renderToDOM(
+ NotFoundPage(config),
+ );
+
+ return {
+ root: html,
+ renderer: "html",
+ destFilePath: "/404.html",
+ href: "/404.html",
+ };
+}
diff --git a/vhosts/blog/nuldoc-src/generators/post.ts b/vhosts/blog/nuldoc-src/generators/post.ts
new file mode 100644
index 00000000..f90ab193
--- /dev/null
+++ b/vhosts/blog/nuldoc-src/generators/post.ts
@@ -0,0 +1,63 @@
+import { join } from "std/path/mod.ts";
+import { renderToDOM } from "../jsx/render.ts";
+import PostPage from "../pages/PostPage.tsx";
+import { Config } from "../config.ts";
+import { Document } from "../ndoc/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;
+}
+
+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 renderToDOM(
+ PostPage(doc, config),
+ );
+
+ const cwd = Deno.cwd();
+ const contentDir = join(cwd, config.locations.contentDir);
+ const destFilePath = join(
+ doc.sourceFilePath.replace(contentDir, "").replace(".ndoc", ""),
+ "index.html",
+ );
+ return {
+ root: html,
+ renderer: "html",
+ 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,
+ };
+}
diff --git a/vhosts/blog/nuldoc-src/generators/post_list.ts b/vhosts/blog/nuldoc-src/generators/post_list.ts
new file mode 100644
index 00000000..67a4b996
--- /dev/null
+++ b/vhosts/blog/nuldoc-src/generators/post_list.ts
@@ -0,0 +1,23 @@
+import { renderToDOM } from "../jsx/render.ts";
+import PostListPage from "../pages/PostListPage.tsx";
+import { Config } from "../config.ts";
+import { Page } from "../page.ts";
+import { PostPage } from "./post.ts";
+
+export type PostListPage = Page;
+
+export async function generatePostListPage(
+ posts: PostPage[],
+ config: Config,
+): Promise<PostListPage> {
+ const html = await renderToDOM(
+ PostListPage(posts, config),
+ );
+
+ return {
+ root: html,
+ renderer: "html",
+ destFilePath: "/posts/index.html",
+ href: "/posts/",
+ };
+}
diff --git a/vhosts/blog/nuldoc-src/generators/slide.ts b/vhosts/blog/nuldoc-src/generators/slide.ts
new file mode 100644
index 00000000..ab68d332
--- /dev/null
+++ b/vhosts/blog/nuldoc-src/generators/slide.ts
@@ -0,0 +1,53 @@
+import { join } from "std/path/mod.ts";
+import { renderToDOM } from "../jsx/render.ts";
+import SlidePage from "../pages/SlidePage.tsx";
+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 renderToDOM(
+ 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",
+ 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/vhosts/blog/nuldoc-src/generators/slide_list.ts b/vhosts/blog/nuldoc-src/generators/slide_list.ts
new file mode 100644
index 00000000..abebe109
--- /dev/null
+++ b/vhosts/blog/nuldoc-src/generators/slide_list.ts
@@ -0,0 +1,23 @@
+import { renderToDOM } from "../jsx/render.ts";
+import SlideListPage from "../pages/SlideListPage.tsx";
+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 renderToDOM(
+ SlideListPage(slides, config),
+ );
+
+ return {
+ root: html,
+ renderer: "html",
+ destFilePath: "/slides/index.html",
+ href: "/slides/",
+ };
+}
diff --git a/vhosts/blog/nuldoc-src/generators/tag.ts b/vhosts/blog/nuldoc-src/generators/tag.ts
new file mode 100644
index 00000000..dbd8ef93
--- /dev/null
+++ b/vhosts/blog/nuldoc-src/generators/tag.ts
@@ -0,0 +1,33 @@
+import { renderToDOM } from "../jsx/render.ts";
+import TagPage from "../pages/TagPage.tsx";
+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[],
+ config: Config,
+): Promise<TagPage> {
+ const html = await renderToDOM(
+ TagPage(tagSlug, pages, config),
+ );
+
+ return {
+ root: html,
+ renderer: "html",
+ 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/vhosts/blog/nuldoc-src/generators/tag_list.ts b/vhosts/blog/nuldoc-src/generators/tag_list.ts
new file mode 100644
index 00000000..7baad8cf
--- /dev/null
+++ b/vhosts/blog/nuldoc-src/generators/tag_list.ts
@@ -0,0 +1,23 @@
+import { renderToDOM } from "../jsx/render.ts";
+import TagListPage from "../pages/TagListPage.tsx";
+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[],
+ config: Config,
+): Promise<TagListPage> {
+ const html = await renderToDOM(
+ TagListPage(tags, config),
+ );
+
+ return {
+ root: html,
+ renderer: "html",
+ destFilePath: "/tags/index.html",
+ href: "/tags/",
+ };
+}
diff --git a/vhosts/blog/nuldoc-src/generators/tagged_page.ts b/vhosts/blog/nuldoc-src/generators/tagged_page.ts
new file mode 100644
index 00000000..23de8cb4
--- /dev/null
+++ b/vhosts/blog/nuldoc-src/generators/tagged_page.ts
@@ -0,0 +1,4 @@
+import { PostPage } from "./post.ts";
+import { SlidePage } from "./slide.ts";
+
+export type TaggedPage = PostPage | SlidePage;
diff --git a/vhosts/blog/nuldoc-src/pages/about.tsx b/vhosts/blog/nuldoc-src/pages/AboutPage.tsx
index 91d7fee4..0000edf5 100644
--- a/vhosts/blog/nuldoc-src/pages/about.tsx
+++ b/vhosts/blog/nuldoc-src/pages/AboutPage.tsx
@@ -3,19 +3,15 @@ import GlobalHeader from "../components/GlobalHeader.tsx";
import PageLayout from "../components/PageLayout.tsx";
import StaticScript from "../components/StaticScript.tsx";
import { Config } from "../config.ts";
-import { renderToDOM } from "../jsx/render.ts";
-import { Page } from "../page.ts";
import { dateToString } from "../revision.ts";
-import { getPostPublishedDate } from "./post.tsx";
-import { SlidePage } from "./slide.tsx";
+import { getPostPublishedDate } from "../generators/post.ts";
+import { SlidePage } from "../generators/slide.ts";
-export type AboutPage = Page;
-
-export async function generateAboutPage(
+export default function AboutPage(
slides: SlidePage[],
config: Config,
-): Promise<AboutPage> {
- const html = await renderToDOM(
+) {
+ return (
<PageLayout
metaCopyrightYear={config.blog.siteCopyrightYear}
metaDescription="このサイトの著者について"
@@ -93,13 +89,6 @@ export async function generateAboutPage(
</main>
<GlobalFooter config={config} />
</body>
- </PageLayout>,
+ </PageLayout>
);
-
- return {
- root: html,
- renderer: "html",
- destFilePath: "/about/index.html",
- href: "/about/",
- };
}
diff --git a/vhosts/blog/nuldoc-src/pages/home.tsx b/vhosts/blog/nuldoc-src/pages/HomePage.tsx
index a9a5d542..8850d039 100644
--- a/vhosts/blog/nuldoc-src/pages/home.tsx
+++ b/vhosts/blog/nuldoc-src/pages/HomePage.tsx
@@ -1,14 +1,10 @@
import GlobalFooter from "../components/GlobalFooter.tsx";
-import { renderToDOM } from "../jsx/render.ts";
import GlobalHeader from "../components/GlobalHeader.tsx";
import PageLayout from "../components/PageLayout.tsx";
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 renderToDOM(
+export default function HomePage(config: Config) {
+ return (
<PageLayout
metaCopyrightYear={config.blog.siteCopyrightYear}
metaDescription="nsfisis のブログサイト"
@@ -52,13 +48,6 @@ export async function generateHomePage(config: Config): Promise<HomePage> {
</main>
<GlobalFooter config={config} />
</body>
- </PageLayout>,
+ </PageLayout>
);
-
- return {
- root: html,
- renderer: "html",
- destFilePath: "/index.html",
- href: "/",
- };
}
diff --git a/vhosts/blog/nuldoc-src/pages/not_found.tsx b/vhosts/blog/nuldoc-src/pages/NotFoundPage.tsx
index 27be0738..9631fef2 100644
--- a/vhosts/blog/nuldoc-src/pages/not_found.tsx
+++ b/vhosts/blog/nuldoc-src/pages/NotFoundPage.tsx
@@ -1,16 +1,12 @@
import GlobalFooter from "../components/GlobalFooter.tsx";
-import { renderToDOM } from "../jsx/render.ts";
import GlobalHeader from "../components/GlobalHeader.tsx";
import PageLayout from "../components/PageLayout.tsx";
import { Config } from "../config.ts";
-import { Page } from "../page.ts";
-export type NotFoundPage = Page;
-
-export async function generateNotFoundPage(
+export default function NotFoundPage(
config: Config,
-): Promise<NotFoundPage> {
- const html = await renderToDOM(
+) {
+ return (
<PageLayout
metaCopyrightYear={config.blog.siteCopyrightYear}
metaDescription="リクエストされたページが見つかりません"
@@ -26,13 +22,6 @@ export async function generateNotFoundPage(
</main>
<GlobalFooter config={config} />
</body>
- </PageLayout>,
+ </PageLayout>
);
-
- return {
- root: html,
- renderer: "html",
- destFilePath: "/404.html",
- href: "/404.html",
- };
}
diff --git a/vhosts/blog/nuldoc-src/pages/post_list.tsx b/vhosts/blog/nuldoc-src/pages/PostListPage.tsx
index 3cf17df4..3fcfbf1f 100644
--- a/vhosts/blog/nuldoc-src/pages/post_list.tsx
+++ b/vhosts/blog/nuldoc-src/pages/PostListPage.tsx
@@ -1,22 +1,18 @@
import GlobalFooter from "../components/GlobalFooter.tsx";
-import { renderToDOM } from "../jsx/render.ts";
import GlobalHeader from "../components/GlobalHeader.tsx";
import PageLayout from "../components/PageLayout.tsx";
import PostPageEntry from "../components/PostPageEntry.tsx";
import { Config } from "../config.ts";
-import { Page } from "../page.ts";
import { dateToString } from "../revision.ts";
-import { getPostPublishedDate, PostPage } from "./post.tsx";
+import { getPostPublishedDate, PostPage } from "../generators/post.ts";
-export type PostListPage = Page;
-
-export async function generatePostListPage(
+export default function PostListPage(
posts: PostPage[],
config: Config,
-): Promise<PostListPage> {
+) {
const pageTitle = "投稿一覧";
- const html = await renderToDOM(
+ return (
<PageLayout
metaCopyrightYear={config.blog.siteCopyrightYear}
metaDescription="投稿した記事の一覧"
@@ -40,13 +36,6 @@ export async function generatePostListPage(
</main>
<GlobalFooter config={config} />
</body>
- </PageLayout>,
+ </PageLayout>
);
-
- return {
- root: html,
- renderer: "html",
- destFilePath: "/posts/index.html",
- href: "/posts/",
- };
}
diff --git a/vhosts/blog/nuldoc-src/pages/post.tsx b/vhosts/blog/nuldoc-src/pages/PostPage.tsx
index 541c33e3..e6aa83aa 100644
--- a/vhosts/blog/nuldoc-src/pages/post.tsx
+++ b/vhosts/blog/nuldoc-src/pages/PostPage.tsx
@@ -1,46 +1,17 @@
-import { join } from "std/path/mod.ts";
-import { renderToDOM } from "../jsx/render.ts";
import GlobalFooter from "../components/GlobalFooter.tsx";
import GlobalHeader from "../components/GlobalHeader.tsx";
import PageLayout from "../components/PageLayout.tsx";
import { Config, getTagLabel } from "../config.ts";
import { Element } from "../dom.ts";
import { Document } from "../ndoc/document.ts";
-import { Page } from "../page.ts";
-import { Date, dateToString, Revision } from "../revision.ts";
+import { dateToString } from "../revision.ts";
+import { getPostPublishedDate } from "../generators/post.ts";
-export interface PostPage extends Page {
- title: string;
- description: string;
- tags: string[];
- revisions: Revision[];
- published: Date;
- updated: Date;
- uuid: 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(
+export default function PostPage(
doc: Document,
config: Config,
-): Promise<PostPage> {
- const html = await renderToDOM(
+) {
+ return (
<PageLayout
metaCopyrightYear={getPostPublishedDate(doc).year}
metaDescription={doc.description}
@@ -98,26 +69,6 @@ export async function generatePostPage(
</main>
<GlobalFooter config={config} />
</body>
- </PageLayout>,
- );
-
- const cwd = Deno.cwd();
- const contentDir = join(cwd, config.locations.contentDir);
- const destFilePath = join(
- doc.sourceFilePath.replace(contentDir, "").replace(".ndoc", ""),
- "index.html",
+ </PageLayout>
);
- return {
- root: html,
- renderer: "html",
- 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,
- };
}
diff --git a/vhosts/blog/nuldoc-src/pages/slide_list.tsx b/vhosts/blog/nuldoc-src/pages/SlideListPage.tsx
index e42cfcea..44d6afff 100644
--- a/vhosts/blog/nuldoc-src/pages/slide_list.tsx
+++ b/vhosts/blog/nuldoc-src/pages/SlideListPage.tsx
@@ -1,23 +1,19 @@
import GlobalFooter from "../components/GlobalFooter.tsx";
-import { renderToDOM } from "../jsx/render.ts";
import GlobalHeader from "../components/GlobalHeader.tsx";
import PageLayout from "../components/PageLayout.tsx";
import SlidePageEntry from "../components/SlidePageEntry.tsx";
import { Config } from "../config.ts";
-import { Page } from "../page.ts";
import { dateToString } from "../revision.ts";
-import { getPostPublishedDate } from "./post.tsx";
-import { SlidePage } from "./slide.tsx";
+import { getPostPublishedDate } from "../generators/post.ts";
+import { SlidePage } from "../generators/slide.ts";
-export type SlideListPage = Page;
-
-export async function generateSlideListPage(
+export default function SlideListPage(
slides: SlidePage[],
config: Config,
-): Promise<SlideListPage> {
+) {
const pageTitle = "スライド一覧";
- const html = await renderToDOM(
+ return (
<PageLayout
metaCopyrightYear={config.blog.siteCopyrightYear}
metaDescription="登壇したイベントで使用したスライドの一覧"
@@ -41,13 +37,6 @@ export async function generateSlideListPage(
</main>
<GlobalFooter config={config} />
</body>
- </PageLayout>,
+ </PageLayout>
);
-
- return {
- root: html,
- renderer: "html",
- destFilePath: "/slides/index.html",
- href: "/slides/",
- };
}
diff --git a/vhosts/blog/nuldoc-src/pages/slide.tsx b/vhosts/blog/nuldoc-src/pages/SlidePage.tsx
index 843f539b..6d167036 100644
--- a/vhosts/blog/nuldoc-src/pages/slide.tsx
+++ b/vhosts/blog/nuldoc-src/pages/SlidePage.tsx
@@ -1,33 +1,17 @@
-import { join } from "std/path/mod.ts";
-import { renderToDOM } from "../jsx/render.ts";
import GlobalFooter from "../components/GlobalFooter.tsx";
import GlobalHeader from "../components/GlobalHeader.tsx";
import PageLayout from "../components/PageLayout.tsx";
import StaticScript from "../components/StaticScript.tsx";
import { Config, getTagLabel } from "../config.ts";
-import { Page } from "../page.ts";
-import { Date, dateToString, Revision } from "../revision.ts";
+import { dateToString } from "../revision.ts";
import { Slide } from "../slide/slide.ts";
-import { getPostPublishedDate, getPostUpdatedDate } from "./post.tsx";
+import { getPostPublishedDate } from "../generators/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(
+export default function SlidePage(
slide: Slide,
config: Config,
-): Promise<SlidePage> {
- const html = await renderToDOM(
+) {
+ return (
<PageLayout
metaCopyrightYear={getPostPublishedDate(slide).year}
metaDescription={slide.title}
@@ -81,29 +65,6 @@ export async function generateSlidePage(
</main>
<GlobalFooter config={config} />
</body>
- </PageLayout>,
- );
-
- const cwd = Deno.cwd();
- const contentDir = join(cwd, config.locations.contentDir);
- const destFilePath = join(
- slide.sourceFilePath.replace(contentDir, "").replace(".toml", ""),
- "index.html",
+ </PageLayout>
);
- return {
- root: html,
- renderer: "html",
- 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/vhosts/blog/nuldoc-src/pages/tag_list.tsx b/vhosts/blog/nuldoc-src/pages/TagListPage.tsx
index 728384f4..cdb83ea5 100644
--- a/vhosts/blog/nuldoc-src/pages/tag_list.tsx
+++ b/vhosts/blog/nuldoc-src/pages/TagListPage.tsx
@@ -1,20 +1,16 @@
import GlobalFooter from "../components/GlobalFooter.tsx";
-import { renderToDOM } from "../jsx/render.ts";
import GlobalHeader from "../components/GlobalHeader.tsx";
import PageLayout from "../components/PageLayout.tsx";
import { Config } from "../config.ts";
-import { Page } from "../page.ts";
-import { TagPage } from "./tag.tsx";
+import { TagPage } from "../generators/tag.ts";
-export type TagListPage = Page;
-
-export async function generateTagListPage(
+export default function TagListPage(
tags: TagPage[],
config: Config,
-): Promise<TagListPage> {
+) {
const pageTitle = "タグ一覧";
- const html = await renderToDOM(
+ return (
<PageLayout
metaCopyrightYear={config.blog.siteCopyrightYear}
metaDescription="タグの一覧"
@@ -56,13 +52,6 @@ export async function generateTagListPage(
</main>
<GlobalFooter config={config} />
</body>
- </PageLayout>,
+ </PageLayout>
);
-
- return {
- root: html,
- renderer: "html",
- destFilePath: "/tags/index.html",
- href: "/tags/",
- };
}
diff --git a/vhosts/blog/nuldoc-src/pages/tag.tsx b/vhosts/blog/nuldoc-src/pages/TagPage.tsx
index f7df1f13..568dfaa6 100644
--- a/vhosts/blog/nuldoc-src/pages/tag.tsx
+++ b/vhosts/blog/nuldoc-src/pages/TagPage.tsx
@@ -1,30 +1,21 @@
import GlobalFooter from "../components/GlobalFooter.tsx";
-import { renderToDOM } from "../jsx/render.ts";
import GlobalHeader from "../components/GlobalHeader.tsx";
import PageLayout from "../components/PageLayout.tsx";
import PostPageEntry from "../components/PostPageEntry.tsx";
import SlidePageEntry from "../components/SlidePageEntry.tsx";
import { Config, getTagLabel } from "../config.ts";
-import { Page } from "../page.ts";
-import { getPostPublishedDate } from "./post.tsx";
-import { TaggedPage } from "./tagged_page.ts";
+import { getPostPublishedDate } from "../generators/post.ts";
+import { TaggedPage } from "../generators/tagged_page.ts";
-export interface TagPage extends Page {
- tagSlug: string;
- tagLabel: string;
- numOfPosts: number;
- numOfSlides: number;
-}
-
-export async function generateTagPage(
+export default function TagPage(
tagSlug: string,
pages: TaggedPage[],
config: Config,
-): Promise<TagPage> {
+) {
const tagLabel = getTagLabel(config, tagSlug);
const pageTitle = `タグ「${tagLabel}」一覧`;
- const html = await renderToDOM(
+ return (
<PageLayout
metaCopyrightYear={getPostPublishedDate(pages[pages.length - 1]).year}
metaDescription={`タグ「${tagLabel}」のついた記事またはスライドの一覧`}
@@ -47,17 +38,6 @@ export async function generateTagPage(
</main>
<GlobalFooter config={config} />
</body>
- </PageLayout>,
+ </PageLayout>
);
-
- return {
- root: html,
- renderer: "html",
- destFilePath: `/tags/${tagSlug}/index.html`,
- href: `/tags/${tagSlug}/`,
- tagSlug: tagSlug,
- tagLabel: tagLabel,
- numOfPosts: pages.filter((p) => !("event" in p)).length,
- numOfSlides: pages.filter((p) => "event" in p).length,
- };
}
diff --git a/vhosts/blog/nuldoc-src/pages/tagged_page.ts b/vhosts/blog/nuldoc-src/pages/tagged_page.ts
deleted file mode 100644
index 026ca91f..00000000
--- a/vhosts/blog/nuldoc-src/pages/tagged_page.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { PostPage } from "./post.tsx";
-import { SlidePage } from "./slide.tsx";
-
-export type TaggedPage = PostPage | SlidePage;