diff options
| author | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-11-07 21:46:24 +0900 |
|---|---|---|
| committer | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-11-07 21:46:24 +0900 |
| commit | f6bdca7dea59e81006a659676a00aae10d2cec58 (patch) | |
| tree | 39aeaf58144520acb281edcdb96321a38e0dfbc7 /astro.config.mjs | |
| parent | 93236c250c5b074d50418aefe8205d1e090b015d (diff) | |
events: 最終更新の日時を1か所に統一
ページ冒頭はビルド時刻、末尾はStarlight標準のgit日時と、2つの日付が
並んでいた。冒頭の表示を内容(ページと予定データ・関連コンポーネント)
の最終コミット時刻にし、dateModifiedとサイトマップのlastmodも同じ
値にそろえた。末尾の重複表示は lastUpdated: false で止めた。
Diffstat (limited to 'astro.config.mjs')
| -rw-r--r-- | astro.config.mjs | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/astro.config.mjs b/astro.config.mjs index 6b6406b..6d155c5 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -8,6 +8,7 @@ import sitemap from "@astrojs/sitemap"; import { unified } from "@astrojs/markdown-remark"; import remarkMermaid from "remark-mermaidjs"; import ogImagePlugin from "./src/plugins/og-image"; +import { SCHEDULE_PAGE_FILES } from "./src/data/schedule/content-files.mjs"; import updatesIntegration from "./src/plugins/updates"; // Apache (production) resolves a directory URL to its index.html, so the site can @@ -73,13 +74,31 @@ const gitDates = buildGitDateMap(); function lastmodFor(url) { const path = url.replace(/^https?:\/\/[^/]+/, "").replace(/^\/+|\/+$/g, ""); const bases = path ? [path, `${path}/index`] : ["index"]; + let pageDate; for (const base of bases) { for (const ext of [".mdx", ".md"]) { const date = gitDates.get(`src/content/docs/${base}${ext}`); - if (date) return new Date(date); + if (date) { + pageDate = new Date(date); + break; + } } + if (pageDate) break; + } + + // 行事予定ページは、ページ本体だけでなく予定データ(JSON)の更新も最終更新に含める。 + // ページ冒頭の「最終更新」と dateModified も同じ値を使っている。 + if (path === "kodaira/events") { + const parts = [ + pageDate, + ...SCHEDULE_PAGE_FILES.map((file) => + gitDates.get(file) ? new Date(gitDates.get(file)) : undefined, + ), + ].filter(Boolean); + if (parts.length) return new Date(Math.max(...parts.map((d) => d.getTime()))); } - return undefined; + + return pageDate; } export default defineConfig({ |
