diff options
| author | Yasutake Yohei <yohei@yasutakeyohei.com> | 2026-07-01 19:32:13 +0900 |
|---|---|---|
| committer | Yasutake Yohei <yohei@yasutakeyohei.com> | 2026-07-01 19:32:13 +0900 |
| commit | 128e82ec1fb21723893d962283814b433ec9bde0 (patch) | |
| tree | 7636ddcf2db4e3058035bb5be37cb4f7cd72e9d5 /src | |
| parent | 1a357e558fb7336761cbd2241d285c6077a11216 (diff) | |
og/index.astro: 一覧ページを自動検出に変更
Diffstat (limited to 'src')
| -rw-r--r-- | src/pages/og/index.astro | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/src/pages/og/index.astro b/src/pages/og/index.astro index 8416098..8bfb7c1 100644 --- a/src/pages/og/index.astro +++ b/src/pages/og/index.astro @@ -1,21 +1,39 @@ --- +import { existsSync, readdirSync } from "node:fs"; +import path from "node:path"; + +const contentDir = "src/content/docs"; + +function findMdxFiles(dir: string): string[] { + if (!existsSync(dir)) return []; + const files: string[] = []; + for (const entry of readdirSync(dir, { withFileTypes: true })) { + if (entry.name.startsWith(".") || entry.name.startsWith("_")) continue; + const full = path.join(dir, entry.name); + if (entry.isDirectory()) files.push(...findMdxFiles(full)); + else if (entry.name.endsWith(".mdx")) files.push(full); + } + return files; +} + const slugs = [ - "index", - "jisseki", - "policy", - "support", - "contact", + "index", "jisseki", "policy", "support", "contact", "whisper-to-ai-moji-okoshi", - "koubunsyo-kanri", - "ijime-judai-jitai", - "fukushi-shisetsu-gyakutai", - "aiki-kouen", - "joutyo-koteikyu", - "kajo-seigen-kanwa", - "saresio-kaihatu", - "vaccine-kyuusai-tekiseika", - "dislexia-taiou", + "koubunsyo-kanri", "ijime-judai-jitai", "fukushi-shisetsu-gyakutai", + "aiki-kouen", "joutyo-koteikyu", "kajo-seigen-kanwa", + "saresio-kaihatu", "vaccine-kyuusai-tekiseika", "dislexia-taiou", "ippan-situmon", + // Auto-discover ippan-situmon sub-pages + ...findMdxFiles(path.join(contentDir, "ippan-situmon")) + .map((f) => + f + .replace(/\\/g, "/") + .replace(contentDir + "/", "") + .replace(/\.mdx$/, "") + .replace(/\/index$/, "") + .replace(/\//g, "-") + ) + .filter((s) => s !== "ippan-situmon"), ]; --- |
