diff options
| author | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-11-06 13:35:26 +0900 |
|---|---|---|
| committer | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-11-06 13:35:26 +0900 |
| commit | fb5a5321822916f8ca9d0599dd6ff5599955e248 (patch) | |
| tree | a125cba22e5dc4b7ed973f2b86f714d48852ea5f /src/components/ScheduleInteractive.astro | |
| parent | fd171825c06456a23f34df3583cd0d4531703115 (diff) | |
events: イベントの構造化データをHTMLに出力
これまでJavaScriptで組み立てていたEventのJSON-LDを、ビルド時に
HTMLへ出すようにした。対象はビルド日から1週間先までの予定で、
名前・開催日・会場を出力する。クライアント側の生成は重複するため外した。
Diffstat (limited to 'src/components/ScheduleInteractive.astro')
| -rw-r--r-- | src/components/ScheduleInteractive.astro | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/src/components/ScheduleInteractive.astro b/src/components/ScheduleInteractive.astro index 8877d9d..19a3f59 100644 --- a/src/components/ScheduleInteractive.astro +++ b/src/components/ScheduleInteractive.astro @@ -1,6 +1,5 @@ <script> // URLは src/data/schedule/config.ts で一元管理している(ページ移転時はそこだけ変える) - import { scheduleAbsoluteUrl } from '@/data/schedule/config'; import { parseDates, applyExclusions, toKey, keyToDate, entryDates, mainStartMonth, normalizeDigits } from '@/lib/schedule-dates'; const CATEGORY_DEFS = [ @@ -486,59 +485,6 @@ }); } - // 検索エンジン向けに、これからのイベントを構造化データ(JSON-LD)で出力する。 - function emitEventStructuredData() { - const upcoming = entries - .filter((e) => e.type === 'event' && e.dates.some((d) => d >= todayKey)) - .map((e) => { - const future = e.dates.filter((d) => d >= todayKey).sort(); - const name = e.name.startsWith(e.category) - ? e.name.slice(e.category.length).trim() - : e.name; - const parts = e.time.split('/'); - const venue = (parts[1] ?? '').trim(); - return { - '@type': 'Event', - name, - startDate: future[0], - eventStatus: 'https://schema.org/EventScheduled', - eventAttendanceMode: 'https://schema.org/OfflineEventAttendanceMode', - location: { - '@type': 'Place', - name: venue || '小平市', - address: { - '@type': 'PostalAddress', - addressLocality: '東京都小平市', - addressCountry: 'JP', - }, - }, - description: e.time, - url: scheduleAbsoluteUrl(`#${e.rowId}`), - }; - }) - .sort((a, b) => a.startDate.localeCompare(b.startDate)) - .slice(0, 40); - - const existing = document.getElementById('schedule-event-ldjson'); - if (existing) existing.remove(); - if (upcoming.length === 0) return; - - const script = document.createElement('script'); - script.type = 'application/ld+json'; - script.id = 'schedule-event-ldjson'; - script.textContent = JSON.stringify({ - '@context': 'https://schema.org', - '@type': 'ItemList', - name: '小平市のこれからのイベント', - itemListElement: upcoming.map((item, index) => ({ - '@type': 'ListItem', - position: index + 1, - item, - })), - }); - document.head.appendChild(script); - } - // 件数はフィルターのボタンには出さず、ページ下部にまとめて表示する。 function renderCategorySummary() { const summaryEl = document.getElementById('schedule-category-summary'); @@ -553,7 +499,6 @@ buildFilters(); renderCategorySummary(); - emitEventStructuredData(); applyFilter(); renderCalendar(); if (selectedDate) showDayDetails(selectedDate); |
