From e72c80197bbcb279a43f4eef81d5ed5a7c13d853 Mon Sep 17 00:00:00 2001 From: grassblock Date: Wed, 4 Jun 2025 18:17:39 +0800 Subject: [PATCH] feat: add PWA support --- src/pages/manifest.json.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/pages/manifest.json.js diff --git a/src/pages/manifest.json.js b/src/pages/manifest.json.js new file mode 100644 index 0000000..2fcf083 --- /dev/null +++ b/src/pages/manifest.json.js @@ -0,0 +1,34 @@ +import { getImage } from 'astro:assets' +import favicon from '../assets/favicon.png' +import { siteConfig } from "../config.js"; +// thanks to https://kremalicious.com/favicon-generation-with-astro +const faviconPngSizes = [192, 512] + +export const GET = async () => { + const icons = await Promise.all( + faviconPngSizes.map(async (size) => { + const image = await getImage({ + src: favicon, + width: size, + height: size, + format: 'png' + }) + return { + src: image.src, + type: `image/${image.options.format}`, + sizes: `${image.options.width}x${image.options.height}` + } + }) + ) + + const manifest = { + name: siteConfig.title, + description: siteConfig.description, + start_url: '/', + display: 'standalone', + id: 'deadbeef-d7d8-4d48-8a7a-593be33d9f77', + icons + } + + return new Response(JSON.stringify(manifest)) +} \ No newline at end of file