summaryrefslogtreecommitdiffhomepage
path: root/vhosts/blog/nuldoc-src/generators/post_list.ts
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-06-27 23:39:31 +0900
committernsfisis <nsfisis@gmail.com>2025-06-27 23:39:31 +0900
commit674fe965550444db87edc7937ff6932e1a918d9d (patch)
treee8a80dd958d3e082485286bf5785a7992b6e6b0e /vhosts/blog/nuldoc-src/generators/post_list.ts
parentfe4d1d625b53796c5f20399790e5ff8c7a7e1608 (diff)
downloadnsfisis.dev-674fe965550444db87edc7937ff6932e1a918d9d.tar.gz
nsfisis.dev-674fe965550444db87edc7937ff6932e1a918d9d.tar.zst
nsfisis.dev-674fe965550444db87edc7937ff6932e1a918d9d.zip
feat(meta): rename vhosts/ directory to services/
Diffstat (limited to 'vhosts/blog/nuldoc-src/generators/post_list.ts')
-rw-r--r--vhosts/blog/nuldoc-src/generators/post_list.ts63
1 files changed, 0 insertions, 63 deletions
diff --git a/vhosts/blog/nuldoc-src/generators/post_list.ts b/vhosts/blog/nuldoc-src/generators/post_list.ts
deleted file mode 100644
index b05f7ee6..00000000
--- a/vhosts/blog/nuldoc-src/generators/post_list.ts
+++ /dev/null
@@ -1,63 +0,0 @@
-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 generatePostListPages(
- posts: PostPage[],
- config: Config,
-): Promise<PostListPage[]> {
- const postsPerPage = config.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 renderToDOM(
- 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",
- destFilePath,
- href,
- };
-}