summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--astro.config.mjs2
-rw-r--r--public/sw.js22
-rw-r--r--src/content/docs/kodaira/events.mdx25
3 files changed, 48 insertions, 1 deletions
diff --git a/astro.config.mjs b/astro.config.mjs
index 958425e..cce2a11 100644
--- a/astro.config.mjs
+++ b/astro.config.mjs
@@ -135,6 +135,8 @@ export default defineConfig({
},
integrations: [
sitemap({
+ // 「今日の予定」アプリの画面は noindex なのでサイトマップには載せない
+ filter: (page) => !page.includes("/kodaira/events/today/"),
serialize(item) {
const lastmod = lastmodFor(item.url);
if (lastmod) item.lastmod = lastmod;
diff --git a/public/sw.js b/public/sw.js
index 571f752..64e8255 100644
--- a/public/sw.js
+++ b/public/sw.js
@@ -1,10 +1,14 @@
// 公園ページはドラフト公開停止中のため、公園ページをAPP_SHELLから外し、
// キャッシュを v2 に更新して旧キャッシュを削除する。公開時に元に戻す。
-const CACHE = "kodaira-parks-v2";
+const CACHE = "kodaira-events-v3";
const APP_SHELL = [
"/manifest.webmanifest",
+ "/manifest-events.webmanifest",
"/icons/icon-192.png",
"/icons/icon-512.png",
+ "/icons/event-192.png",
+ "/icons/event-512.png",
+ "/kodaira/events/today/",
];
self.addEventListener("install", (event) => {
@@ -49,6 +53,22 @@ self.addEventListener("fetch", (event) => {
return;
}
+ // アプリ用データ(data.json)は新しい内容を優先し、オフライン時はキャッシュを使う。
+ if (url.pathname === "/kodaira/events/data.json") {
+ event.respondWith(
+ fetch(request)
+ .then((response) => {
+ if (response.ok) {
+ const copy = response.clone();
+ caches.open(CACHE).then((cache) => cache.put(request, copy));
+ }
+ return response;
+ })
+ .catch(() => caches.match(request)),
+ );
+ return;
+ }
+
// それ以外はキャッシュ優先。取得できたらキャッシュを更新する。
event.respondWith(
caches.match(request).then((cached) => {
diff --git a/src/content/docs/kodaira/events.mdx b/src/content/docs/kodaira/events.mdx
index 3e7f04c..8bebcc4 100644
--- a/src/content/docs/kodaira/events.mdx
+++ b/src/content/docs/kodaira/events.mdx
@@ -10,6 +10,31 @@ head:
type: application/rss+xml
title: 小平市のイベント・行事予定(RSS)
href: /kodaira/events/feed.xml
+ - tag: link
+ attrs:
+ rel: manifest
+ href: /manifest-events.webmanifest
+ - tag: meta
+ attrs:
+ name: theme-color
+ content: "#1565c0"
+ - tag: link
+ attrs:
+ rel: apple-touch-icon
+ href: /icons/event-192.png
+ - tag: meta
+ attrs:
+ name: apple-mobile-web-app-capable
+ content: "yes"
+ - tag: meta
+ attrs:
+ name: apple-mobile-web-app-title
+ content: 今日の小平市
+ - tag: link
+ attrs:
+ rel: alternate
+ title: 今日と明日の予定(アプリ)
+ href: /kodaira/events/today/
---
import ScheduleInteractive from '../../../components/ScheduleInteractive.astro';