mirror of
https://github.com/kbenestad/mdcms.git
synced 2026-06-18 07:24:31 +00:00
Add M favicon, fix manifest for PWA installability
- Generate 192x192 blue/white M icon as favicon.png - manifest.json: add id field, proper icon sizes (192/512), purpose: any - mdcms.py generate_pwa(): respect favicon config key, skip icons if file missing, emit id and correct sizes https://claude.ai/code/session_01UP8Wo2CKPNhvvTkzX48CWF
This commit is contained in:
parent
a9e48ffee4
commit
9856a94d26
4 changed files with 93 additions and 5 deletions
BIN
app/assets/images/favicon.png
Normal file
BIN
app/assets/images/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 747 B |
23
app/manifest.json
Normal file
23
app/manifest.json
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"id": "/",
|
||||
"name": "MD-CMS Phase 7 Test",
|
||||
"short_name": "MDCMS Test",
|
||||
"start_url": "./",
|
||||
"display": "standalone",
|
||||
"background_color": "#ffffff",
|
||||
"theme_color": "#2563EB",
|
||||
"icons": [
|
||||
{
|
||||
"src": "assets/images/favicon.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png",
|
||||
"purpose": "any"
|
||||
},
|
||||
{
|
||||
"src": "assets/images/favicon.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png",
|
||||
"purpose": "any"
|
||||
}
|
||||
]
|
||||
}
|
||||
57
app/service-worker.js
Normal file
57
app/service-worker.js
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
// mdcms service worker — generated by mdcms build
|
||||
const CACHE_NAME = 'mdcms-eb384247';
|
||||
const PRECACHE_URLS = [
|
||||
"index.html",
|
||||
"config.yml",
|
||||
"nav.yml",
|
||||
"search.json",
|
||||
"theme.yml",
|
||||
"pages/about.md",
|
||||
"pages/docs.md",
|
||||
"pages/home.md",
|
||||
"posts/.gitkeep",
|
||||
"assets/fonts/.gitkeep",
|
||||
"assets/icons/.gitkeep",
|
||||
"assets/icons/arrow_drop_down.svg",
|
||||
"assets/icons/arrow_right.svg",
|
||||
"assets/icons/dangerous.svg",
|
||||
"assets/icons/dark_mode.svg",
|
||||
"assets/icons/error.svg",
|
||||
"assets/icons/exclamation.svg",
|
||||
"assets/icons/history.svg",
|
||||
"assets/icons/info.svg",
|
||||
"assets/icons/language.svg",
|
||||
"assets/icons/light_mode.svg",
|
||||
"assets/icons/menu.svg",
|
||||
"assets/icons/mobile_arrow_down.svg",
|
||||
"assets/icons/report.svg",
|
||||
"assets/icons/search.svg",
|
||||
"assets/icons/success.svg",
|
||||
"assets/icons/text_compare.svg",
|
||||
"assets/icons/warning.svg",
|
||||
"assets/images/.gitkeep",
|
||||
"assets/images/favicon.png"
|
||||
];
|
||||
|
||||
self.addEventListener('install', event => {
|
||||
event.waitUntil(
|
||||
caches.open(CACHE_NAME).then(cache => cache.addAll(PRECACHE_URLS))
|
||||
);
|
||||
self.skipWaiting();
|
||||
});
|
||||
|
||||
self.addEventListener('activate', event => {
|
||||
event.waitUntil(
|
||||
caches.keys().then(keys =>
|
||||
Promise.all(keys.filter(k => k !== CACHE_NAME).map(k => caches.delete(k)))
|
||||
)
|
||||
);
|
||||
self.clients.claim();
|
||||
});
|
||||
|
||||
self.addEventListener('fetch', event => {
|
||||
if (event.request.method !== 'GET') return;
|
||||
event.respondWith(
|
||||
caches.match(event.request).then(cached => cached || fetch(event.request))
|
||||
);
|
||||
});
|
||||
14
mdcms.py
14
mdcms.py
|
|
@ -503,18 +503,26 @@ def generate_pwa(site_path: Path, cfg: dict):
|
|||
pwa_name = cfg.get("pwa-name", cfg.get("sitename", "MD-CMS Site"))
|
||||
pwa_shortname = cfg.get("pwa-shortname", pwa_name)
|
||||
pwa_colour = cfg.get("pwa-colour", "#2563EB")
|
||||
favicon = cfg.get("favicon", "favicon.png")
|
||||
icon_src = f"assets/images/{favicon}"
|
||||
|
||||
icons = []
|
||||
if (site_path / icon_src).exists():
|
||||
icons = [
|
||||
{"src": icon_src, "sizes": "192x192", "type": "image/png", "purpose": "any"},
|
||||
{"src": icon_src, "sizes": "512x512", "type": "image/png", "purpose": "any"},
|
||||
]
|
||||
|
||||
# manifest.json
|
||||
manifest = {
|
||||
"id": "/",
|
||||
"name": pwa_name,
|
||||
"short_name": pwa_shortname,
|
||||
"start_url": "./",
|
||||
"display": "standalone",
|
||||
"background_color": "#ffffff",
|
||||
"theme_color": pwa_colour,
|
||||
"icons": [
|
||||
{"src": "assets/images/favicon.png", "sizes": "any", "type": "image/png"}
|
||||
],
|
||||
"icons": icons,
|
||||
}
|
||||
(site_path / "manifest.json").write_text(
|
||||
json.dumps(manifest, indent=2, ensure_ascii=False), encoding="utf-8"
|
||||
|
|
|
|||
Loading…
Reference in a new issue