summaryrefslogtreecommitdiffhomepage
path: root/services/blog/nuldoc-src/components
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 /services/blog/nuldoc-src/components
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 'services/blog/nuldoc-src/components')
-rw-r--r--services/blog/nuldoc-src/components/GlobalFooter.tsx9
-rw-r--r--services/blog/nuldoc-src/components/GlobalHeader.tsx27
-rw-r--r--services/blog/nuldoc-src/components/PageLayout.tsx61
-rw-r--r--services/blog/nuldoc-src/components/Pagination.tsx45
-rw-r--r--services/blog/nuldoc-src/components/PostPageEntry.tsx39
-rw-r--r--services/blog/nuldoc-src/components/SlidePageEntry.tsx39
-rw-r--r--services/blog/nuldoc-src/components/StaticScript.tsx18
-rw-r--r--services/blog/nuldoc-src/components/StaticStylesheet.tsx11
-rw-r--r--services/blog/nuldoc-src/components/utils.ts8
9 files changed, 257 insertions, 0 deletions
diff --git a/services/blog/nuldoc-src/components/GlobalFooter.tsx b/services/blog/nuldoc-src/components/GlobalFooter.tsx
new file mode 100644
index 00000000..757beced
--- /dev/null
+++ b/services/blog/nuldoc-src/components/GlobalFooter.tsx
@@ -0,0 +1,9 @@
+import { Config } from "../config.ts";
+
+export default function GlobalFooter({ config }: { config: Config }) {
+ return (
+ <footer className="footer">
+ {`&copy; ${config.blog.siteCopyrightYear} ${config.blog.author}`}
+ </footer>
+ );
+}
diff --git a/services/blog/nuldoc-src/components/GlobalHeader.tsx b/services/blog/nuldoc-src/components/GlobalHeader.tsx
new file mode 100644
index 00000000..c0fa7e8b
--- /dev/null
+++ b/services/blog/nuldoc-src/components/GlobalHeader.tsx
@@ -0,0 +1,27 @@
+import { Config } from "../config.ts";
+
+export default function GlobalHeader({ config }: { config: Config }) {
+ return (
+ <header className="header">
+ <div className="site-logo">
+ <a href="/">{config.blog.siteName}</a>
+ </div>
+ <nav className="nav">
+ <ul>
+ <li>
+ <a href="/about/">About</a>
+ </li>
+ <li>
+ <a href="/posts/">Posts</a>
+ </li>
+ <li>
+ <a href="/slides/">Slides</a>
+ </li>
+ <li>
+ <a href="/tags/">Tags</a>
+ </li>
+ </ul>
+ </nav>
+ </header>
+ );
+}
diff --git a/services/blog/nuldoc-src/components/PageLayout.tsx b/services/blog/nuldoc-src/components/PageLayout.tsx
new file mode 100644
index 00000000..1cd0aebf
--- /dev/null
+++ b/services/blog/nuldoc-src/components/PageLayout.tsx
@@ -0,0 +1,61 @@
+import { Config } from "../config.ts";
+import { JSXNode } from "myjsx/jsx-runtime";
+import StaticStylesheet from "./StaticStylesheet.tsx";
+
+type Props = {
+ metaCopyrightYear: number;
+ metaDescription: string;
+ metaKeywords?: string[];
+ metaTitle: string;
+ metaAtomFeedHref?: string;
+ requiresSyntaxHighlight?: boolean;
+ config: Config;
+ children: JSXNode;
+};
+
+export default function PageLayout(
+ {
+ metaCopyrightYear,
+ metaDescription,
+ metaKeywords,
+ metaTitle,
+ metaAtomFeedHref,
+ requiresSyntaxHighlight: _,
+ config,
+ children,
+ }: Props,
+) {
+ return (
+ <html lang="ja-JP">
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta name="author" content={config.blog.author} />
+ <meta
+ name="copyright"
+ content={`&copy; ${metaCopyrightYear} ${config.blog.author}`}
+ />
+ <meta name="description" content={metaDescription} />
+ {metaKeywords && metaKeywords.length !== 0 &&
+ <meta name="keywords" content={metaKeywords.join(",")} />}
+ <meta property="og:type" content="article" />
+ <meta property="og:title" content={metaTitle} />
+ <meta property="og:description" content={metaDescription} />
+ <meta property="og:site_name" content={config.blog.siteName} />
+ <meta property="og:locale" content="ja_JP" />
+ {metaAtomFeedHref &&
+ (
+ <link
+ rel="alternate"
+ href={metaAtomFeedHref}
+ type="application/atom+xml"
+ />
+ )}
+ <link rel="icon" href="/favicon.svg" type="image/svg+xml" />
+ <title>{metaTitle}</title>
+ <StaticStylesheet fileName="/style.css" config={config} />
+ </head>
+ {children}
+ </html>
+ );
+}
diff --git a/services/blog/nuldoc-src/components/Pagination.tsx b/services/blog/nuldoc-src/components/Pagination.tsx
new file mode 100644
index 00000000..5527c924
--- /dev/null
+++ b/services/blog/nuldoc-src/components/Pagination.tsx
@@ -0,0 +1,45 @@
+type Props = {
+ currentPage: number;
+ totalPages: number;
+ basePath: string;
+};
+
+export default function Pagination(
+ { currentPage, totalPages, basePath }: Props,
+) {
+ if (totalPages <= 1) {
+ return <div></div>;
+ }
+
+ const prevPage = currentPage > 1 ? currentPage - 1 : null;
+ const nextPage = currentPage < totalPages ? currentPage + 1 : null;
+
+ const prevHref = prevPage === 1 ? basePath : `${basePath}${prevPage}/`;
+ const nextHref = `${basePath}${nextPage}/`;
+
+ return (
+ <nav className="pagination">
+ <div className="pagination-prev">
+ {prevPage
+ ? (
+ <a href={prevHref}>
+ 前のページ
+ </a>
+ )
+ : null}
+ </div>
+ <div className="pagination-info">
+ {String(currentPage)} / {String(totalPages)}
+ </div>
+ <div className="pagination-next">
+ {nextPage
+ ? (
+ <a href={nextHref}>
+ 次のページ
+ </a>
+ )
+ : null}
+ </div>
+ </nav>
+ );
+}
diff --git a/services/blog/nuldoc-src/components/PostPageEntry.tsx b/services/blog/nuldoc-src/components/PostPageEntry.tsx
new file mode 100644
index 00000000..2708b009
--- /dev/null
+++ b/services/blog/nuldoc-src/components/PostPageEntry.tsx
@@ -0,0 +1,39 @@
+import {
+ getPostPublishedDate,
+ getPostUpdatedDate,
+ postHasAnyUpdates,
+ PostPage,
+} from "../generators/post.ts";
+import { dateToString } from "../revision.ts";
+
+export default function PostPageEntry({ post }: { post: PostPage }) {
+ return (
+ <article className="post-entry">
+ <a href={post.href}>
+ <header className="entry-header">
+ <h2>{post.title}</h2>
+ </header>
+ <section className="entry-content">
+ <p>{post.description}</p>
+ </section>
+ <footer className="entry-footer">
+ <time datetime={dateToString(getPostPublishedDate(post))}>
+ {dateToString(getPostPublishedDate(post))}
+ </time>
+ {" 投稿"}
+ {
+ // TODO(jsx): support Fragment and merge them.
+ postHasAnyUpdates(post) && "、"
+ }
+ {postHasAnyUpdates(post) &&
+ (
+ <time datetime={dateToString(getPostUpdatedDate(post))}>
+ {dateToString(getPostUpdatedDate(post))}
+ </time>
+ )}
+ {postHasAnyUpdates(post) && " 更新"}
+ </footer>
+ </a>
+ </article>
+ );
+}
diff --git a/services/blog/nuldoc-src/components/SlidePageEntry.tsx b/services/blog/nuldoc-src/components/SlidePageEntry.tsx
new file mode 100644
index 00000000..d2cf9a17
--- /dev/null
+++ b/services/blog/nuldoc-src/components/SlidePageEntry.tsx
@@ -0,0 +1,39 @@
+import {
+ getPostPublishedDate,
+ getPostUpdatedDate,
+ postHasAnyUpdates,
+} from "../generators/post.ts";
+import { SlidePage } from "../generators/slide.ts";
+import { dateToString } from "../revision.ts";
+
+export default function SlidePageEntry({ slide }: { slide: SlidePage }) {
+ return (
+ <article className="post-entry">
+ <a href={slide.href}>
+ <header className="entry-header">
+ <h2>{slide.description}</h2>
+ </header>
+ <section className="entry-content">
+ <p>{slide.title}</p>
+ </section>
+ <footer className="entry-footer">
+ <time datetime={dateToString(getPostPublishedDate(slide))}>
+ {dateToString(getPostPublishedDate(slide))}
+ </time>
+ {" 登壇"}
+ {
+ // TODO(jsx): support Fragment and merge them.
+ postHasAnyUpdates(slide) && "、"
+ }
+ {postHasAnyUpdates(slide) &&
+ (
+ <time datetime={dateToString(getPostUpdatedDate(slide))}>
+ {dateToString(getPostUpdatedDate(slide))}
+ </time>
+ )}
+ {postHasAnyUpdates(slide) && " 更新"}
+ </footer>
+ </a>
+ </article>
+ );
+}
diff --git a/services/blog/nuldoc-src/components/StaticScript.tsx b/services/blog/nuldoc-src/components/StaticScript.tsx
new file mode 100644
index 00000000..0e3ab194
--- /dev/null
+++ b/services/blog/nuldoc-src/components/StaticScript.tsx
@@ -0,0 +1,18 @@
+import { join } from "@std/path";
+import { Config } from "../config.ts";
+import { calculateFileHash } from "./utils.ts";
+
+export default async function StaticScript(
+ { fileName, type, defer, config }: {
+ fileName: string;
+ type?: string;
+ defer?: "true";
+ config: Config;
+ },
+) {
+ const filePath = join(Deno.cwd(), config.locations.staticDir, fileName);
+ const hash = await calculateFileHash(filePath);
+ return (
+ <script src={`${fileName}?h=${hash}`} type={type} defer={defer}></script>
+ );
+}
diff --git a/services/blog/nuldoc-src/components/StaticStylesheet.tsx b/services/blog/nuldoc-src/components/StaticStylesheet.tsx
new file mode 100644
index 00000000..52b695e5
--- /dev/null
+++ b/services/blog/nuldoc-src/components/StaticStylesheet.tsx
@@ -0,0 +1,11 @@
+import { join } from "@std/path";
+import { Config } from "../config.ts";
+import { calculateFileHash } from "./utils.ts";
+
+export default async function StaticStylesheet(
+ { fileName, config }: { fileName: string; config: Config },
+) {
+ const filePath = join(Deno.cwd(), config.locations.staticDir, fileName);
+ const hash = await calculateFileHash(filePath);
+ return <link rel="stylesheet" href={`${fileName}?h=${hash}`} />;
+}
diff --git a/services/blog/nuldoc-src/components/utils.ts b/services/blog/nuldoc-src/components/utils.ts
new file mode 100644
index 00000000..14059b5b
--- /dev/null
+++ b/services/blog/nuldoc-src/components/utils.ts
@@ -0,0 +1,8 @@
+import { Hash } from "checksum/mod.ts";
+
+export async function calculateFileHash(
+ filePath: string,
+): Promise<string> {
+ const content = await Deno.readFile(filePath);
+ return new Hash("md5").digest(content).hex();
+}