diff options
| author | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-11-23 09:42:59 +0900 |
|---|---|---|
| committer | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-11-23 09:42:59 +0900 |
| commit | be3c9c978843453c46a599792450d9750d005630 (patch) | |
| tree | b39f2a696f2a26db7dbe7f580d8af5c2f30ded15 | |
| parent | 62dbaa5be02a22cd97a828c8b1309d0459b8c777 (diff) | |
events.json: 図書館・小金井公園・ふるさと村の新着を反映
- 障害者週間特別展示(11/28〜12/16、市内全図書館)を追加
- 小金井公園 防災フェスタ2026(12/6)を追加
- 小平ふるさと村 お芝居ワークショップ「ひみつきち」(12/12・13)を追加
- update-library-dates.mjs を events.json 対応に修正(ページ移転で動かなくなっていた)
| -rw-r--r-- | scripts/update-library-dates.mjs | 32 | ||||
| -rw-r--r-- | src/data/schedule/events.json | 21 |
2 files changed, 36 insertions, 17 deletions
diff --git a/scripts/update-library-dates.mjs b/scripts/update-library-dates.mjs index 2317b17..74b9302 100644 --- a/scripts/update-library-dates.mjs +++ b/scripts/update-library-dates.mjs @@ -25,7 +25,7 @@ const targetIdx = args.indexOf('--target'); const targetPath = targetIdx >= 0 ? args[targetIdx + 1] - : path.join('src', 'content', 'docs', 'kodaira-data', 'hp-archive', 'schedule.mdx'); + : path.join('src', 'data', 'schedule', 'events.json'); async function fetchText(url) { const res = await fetch(url, { headers: { 'User-Agent': UA } }); @@ -99,30 +99,28 @@ function formatDates(dateKeys, withWeekday) { } // 図書館のページ(info.html?id=…)を出典に含む行を対象にする。 -// 市報など他の出典と併記している行(例:「市報こだいら10月20日号3面/[図書館のページ](…)」)も拾う。 -const ROW_RE = - /^\| ([^|]*) \| ([^|]*) \| ([^|]*) \| ([^|]*) \| ([^|]*library\.kodaira\.ed\.jp\/viewer\/info\.html\?id=(\d+)[^|]*) \|$/; +// 市報など他の出典と併記している行(例:「市報こだいら10月20日号3面/<a …info.html?id=…>」)も拾う。 +const LIB_SOURCE_RE = /library\.kodaira\.ed\.jp\/viewer\/info\.html\?id=(\d+)/; async function main() { const events = await collectEvents(); - const src = fs.readFileSync(targetPath, 'utf8'); - const lines = src.split('\n'); + const data = JSON.parse(fs.readFileSync(targetPath, 'utf8')); + const rows = data.rows; const inTable = new Map(); const changes = []; - lines.forEach((line, index) => { - // Windows の CRLF でも一致するよう、照合時だけ行末の \r を除く - const m = line.replace(/\r$/, '').match(ROW_RE); - if (!m) return; - const [, datesCell, name, , , , id] = m; - inTable.set(id, { index, name, datesCell }); + for (const row of rows) { + const m = (row.source || '').match(LIB_SOURCE_RE); + if (!m) continue; + const id = m[1]; + inTable.set(id, { name: row.title, datesCell: row.date, row }); const ev = events.get(id); - if (!ev || ev.dates.size === 0) return; + if (!ev || ev.dates.size === 0) continue; const next = formatDates(ev.dates, ev.dates.size === 1); - if (next !== datesCell) changes.push({ index, name, id, from: datesCell, to: next }); - }); + if (next !== row.date) changes.push({ name: row.title, id, from: row.date, to: next, row }); + } console.log(`図書館の予定: カレンダー ${events.size}件 / 表 ${inTable.size}件(${months}か月分を取得)`); @@ -133,7 +131,7 @@ async function main() { console.log(`- ${c.name}`); console.log(` 現在: ${c.from}`); console.log(` 新規: ${c.to}`); - if (apply) lines[c.index] = lines[c.index].replace(`| ${c.from} |`, `| ${c.to} |`); + if (apply) c.row.date = c.to; } } @@ -152,7 +150,7 @@ async function main() { } if (apply && changes.length > 0) { - fs.writeFileSync(targetPath, lines.join('\n'), 'utf8'); + fs.writeFileSync(targetPath, JSON.stringify(data, null, 2) + '\n', 'utf8'); console.log(`\n${changes.length}件を ${targetPath} に反映しました。`); } else if (!apply && changes.length > 0) { console.log('\n(--apply を付けると反映します)'); diff --git a/src/data/schedule/events.json b/src/data/schedule/events.json index 28f1ec2..03b1fe2 100644 --- a/src/data/schedule/events.json +++ b/src/data/schedule/events.json @@ -2372,6 +2372,27 @@ "place": "東京都薬用植物園", "note": "11月17日から申込み、先着20人。詳しくは東京生薬協会のページをご覧ください。", "source": "<a href=\"https://www.tokyo-shoyaku.com/evs.php\">東京生薬協会</a>" + }, + { + "date": "11月28日(土)〜12月16日(水)", + "title": "📚 障害者週間特別展示「活字による読書が困難な方へ」", + "place": "市内全図書館(分室を除く)", + "note": "視覚障がいや高齢などの理由で活字による読書が困難な方向けの資料・機器を展示します。中央図書館は大活字本、朗読CD、録音・点字図書、布の絵本・遊具。大沼図書館は大活字本、録音図書、布の絵本・遊具。それ以外の図書館は大活字本。展示している資料・機器は貸出もできます。中央図書館 042-345-1246", + "source": "<a href=\"https://library.kodaira.ed.jp/viewer/info.html?id=426\">図書館のページ</a>" + }, + { + "date": "12月6日(日)", + "title": "🌳 小金井公園 防災フェスタ2026", + "place": "午前10時から午後2時まで(雨天中止)/小金井公園 いこいの広場", + "note": "自助・共助を広める団体と、公助を担う機関が集まります。小金井市役所、小平市役所、西東京市役所、小金井消防署、小金井警察署、自衛隊、病院、江戸東京たてもの園、キッチンカーなどが出展。インクルーシブウォークラリー、三助スタンプラリーなど。", + "source": "<a href=\"https://www.tokyo-park.or.jp/park/koganei/news/2026/12_6_2026.html\">小金井公園</a>" + }, + { + "date": "12月12日(土)・13日(日)", + "title": "🎨 小平ふるさと村 お芝居ワークショップ「ひみつきち」(全2回)", + "place": "午後1時30分から午後3時30分まで/小平ふるさと村", + "note": "小学生以上で演劇に興味のある方(小学高学年〜中高生歓迎)。定員10人、参加費無料。劇遊び、ショートシーン創作。2回のうち1回だけの参加も可。12月9日(水)までに小平ふるさと村へ電話(042-345-8155)または申込みサイトから(申込み多数の場合は抽選)。主催は公益財団法人小平市文化振興財団・小平ふるさと村", + "source": "<a href=\"http://kodaira-furusatomura.jp/detail/z00182.html\">小平ふるさと村</a>" } ] } |
