From f6bdca7dea59e81006a659676a00aae10d2cec58 Mon Sep 17 00:00:00 2001 From: Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> Date: Sat, 7 Nov 2026 21:46:24 +0900 Subject: events: 最終更新の日時を1か所に統一 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ページ冒頭はビルド時刻、末尾はStarlight標準のgit日時と、2つの日付が 並んでいた。冒頭の表示を内容(ページと予定データ・関連コンポーネント) の最終コミット時刻にし、dateModifiedとサイトマップのlastmodも同じ 値にそろえた。末尾の重複表示は lastUpdated: false で止めた。 --- astro.config.mjs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'astro.config.mjs') 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({ -- cgit v1.3.1