--- // 小平市の公園一覧(/kodaira-data/parks/)を表示する。 // データは src/data/kodaira-parks.json(321件、市の公開資料から作成)。 // 町名セレクトとキーワード入力で絞り込む(絞り込みは利用者の端末で実行)。 import parksData from "@/data/kodaira-parks.json"; type Park = Record; const parks = parksData as Park[]; const EMPTY = "—"; const columns: { key: string; label: string; numeric?: boolean; wide?: boolean }[] = [ { key: "公園名", label: "公園名" }, { key: "住所", label: "住所" }, { key: "面積㎡", label: "面積(㎡)", numeric: true }, { key: "500㎡以上", label: "500㎡以上" }, { key: "種別", label: "種別" }, { key: "南西部指定管理", label: "南西部指定管理" }, { key: "トイレ", label: "トイレ", wide: true }, { key: "水飲み場", label: "水飲み場" }, { key: "ベンチ・椅子", label: "ベンチ・椅子", wide: true }, { key: "テーブル", label: "テーブル", wide: true }, { key: "防災用具", label: "防災用具", wide: true }, { key: "ボール遊び", label: "ボール遊び", wide: true }, { key: "遊具", label: "遊具", wide: true }, { key: "備考", label: "備考", wide: true }, ]; function display(key: string, value: string): string { if (value === "" || value == null) return EMPTY; if (key === "面積㎡") { const n = Number(value); if (Number.isFinite(n)) return n.toLocaleString("ja-JP"); } return value; } // 検索対象(公園名・住所・町名・種別・ボール遊び・遊具・備考)。 function searchIndex(p: Park): string { return [ p["公園名"], p["住所"], p["町名"], p["種別"], p["ボール遊び"], p["遊具"], p["備考"], ] .join(" ") .toLowerCase(); } const towns = [...new Set(parks.map((p) => p["町名"]))].sort((a, b) => a.localeCompare(b, "ja"), ); const total = parks.length; ---
{total}件
{columns.map((col) => ( ))} {parks.map((park) => ( {columns.map((col) => ( ))} ))}
{col.label}
{display(col.key, park[col.key])}