aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-11-05 14:17:54 +0900
committerYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-11-05 14:17:54 +0900
commitfd377d1df26df4643f8028677b027327d397f121 (patch)
treeba5a9556d5c174916075f0fa5f4c3ac772624242
parentc43be8eb6718ad4c3019fe150ed395e8c73abf2d (diff)
events: 旧URLの転送をAstro側にも定義
.htaccessは本番のApacheでしか効かず、astro devでは旧URLが404に なっていた。config の redirects と動的ルートで同じ301転送を用意した。
-rw-r--r--astro.config.mjs7
-rw-r--r--src/pages/kodaira-data/events/[...path].astro13
2 files changed, 20 insertions, 0 deletions
diff --git a/astro.config.mjs b/astro.config.mjs
index 03c5b9e..6b6406b 100644
--- a/astro.config.mjs
+++ b/astro.config.mjs
@@ -87,6 +87,13 @@ export default defineConfig({
base: "/",
trailingSlash: "always",
compressHTML: true,
+ // 旧URLからの転送。本番は .htaccess が301で返すが、astro dev / preview では
+ // .htaccess が効かないため、ここでも同じ転送を定義しておく。
+ redirects: {
+ "/kodaira-data/hp-archive/schedule": "/kodaira/events/",
+ "/kodaira-data/schedule": "/kodaira/events/",
+ "/kodaira-data/events": "/kodaira/events/",
+ },
image: {
layout: "constrained",
responsiveStyles: true,
diff --git a/src/pages/kodaira-data/events/[...path].astro b/src/pages/kodaira-data/events/[...path].astro
new file mode 100644
index 0000000..e09cc30
--- /dev/null
+++ b/src/pages/kodaira-data/events/[...path].astro
@@ -0,0 +1,13 @@
+---
+// 旧URL(/kodaira-data/events/2026-11/ など)から新しいURLへの転送。
+// 本番のApacheは public/.htaccess が301で返す。astro dev / preview では
+// .htaccess が効かないため、ここで同じ転送を用意しておく。
+import { fiscalYearKeys, monthKeys } from '@/lib/schedule-months';
+
+export function getStaticPaths() {
+ return [...monthKeys, ...fiscalYearKeys].map((path) => ({ params: { path } }));
+}
+
+const { path } = Astro.params;
+return Astro.redirect(`/kodaira/events/${path}/`, 301);
+---