diff --git a/README.md b/README.md index e804335..c3508f8 100644 --- a/README.md +++ b/README.md @@ -193,12 +193,7 @@ Static files served directly to the browser are within the `public` directory at public/ ├── apple-touch-icon.png ├── favicon.ico -├── icon-192.png -├── icon-512.png ├── icon.svg -├── manifest.webmanifest -├── maskable_icon.png -├── maskable_icon_x512.png ├── scripts/ │ └── vendor/ │ ├── gsap/ # Animations powered by GSAP (GreenSock Animation Platform) diff --git a/public/icon-192.png b/public/icon-192.png deleted file mode 100644 index 7a83b88..0000000 Binary files a/public/icon-192.png and /dev/null differ diff --git a/public/manifest.webmanifest b/public/manifest.webmanifest deleted file mode 100644 index ac95964..0000000 --- a/public/manifest.webmanifest +++ /dev/null @@ -1,35 +0,0 @@ -{ - "short_name": "ScrewFast", - "name": "ScrewFast", - "icons": [ - { - "src": "/icon-192.png", - "sizes": "192x192", - "type": "image/png", - "purpose": "any" - }, - { - "src": "/icon-512.png", - "sizes": "512x512", - "type": "image/png", - "purpose": "any" - }, - { - "src": "/maskable_icon_x512.png", - "sizes": "512x512", - "type": "image/png", - "purpose": "maskable" - }, - { - "src": "/maskable_icon.png", - "sizes": "1000x1000", - "type": "image/png", - "purpose": "maskable" - } - ], - "display": "minimal-ui", - "id": "/", - "start_url": "/", - "theme_color": "#FFEDD5", - "background_color": "#262626" - } \ No newline at end of file diff --git a/public/maskable_icon_x512.png b/public/maskable_icon_x512.png deleted file mode 100644 index 0c37558..0000000 Binary files a/public/maskable_icon_x512.png and /dev/null differ diff --git a/src/components/Meta.astro b/src/components/Meta.astro index d642a37..0a905ef 100644 --- a/src/components/Meta.astro +++ b/src/components/Meta.astro @@ -73,7 +73,7 @@ const socialImage: string = `${Astro.site}/social.png`; // Set the path for the - + diff --git a/public/maskable_icon.png b/src/images/icon-maskable.png similarity index 100% rename from public/maskable_icon.png rename to src/images/icon-maskable.png diff --git a/public/icon-512.png b/src/images/icon.png similarity index 100% rename from public/icon-512.png rename to src/images/icon.png diff --git a/src/pages/manifest.json.ts b/src/pages/manifest.json.ts new file mode 100644 index 0000000..26fd13c --- /dev/null +++ b/src/pages/manifest.json.ts @@ -0,0 +1,64 @@ +import type { APIRoute, ImageMetadata } from "astro"; +import { getImage } from "astro:assets"; +import icon from "@/images/icon.png"; +import maskableIcon from "@/images/icon-maskable.png"; + +interface Favicon { + purpose: 'any' | 'maskable' | 'monochrome'; + src: ImageMetadata; + sizes: number[]; +} + +const sizes = [192, 512]; +const favicons: Favicon[] = [ + { + purpose: 'any', + src: icon, + sizes, + }, + { + purpose: 'maskable', + src: maskableIcon, + sizes, + }, +]; + +console.log(favicons); + +export const GET: APIRoute = async () => { + const icons = await Promise.all( + favicons.flatMap((favicon) => + favicon.sizes.map(async (size) => { + const image = await getImage({ + src: favicon.src, + width: size, + height: size, + format: "png", + }); + return { + src: image.src, + sizes: `${image.options.width}x${image.options.height}`, + type: `image/${image.options.format}`, + purpose: favicon.purpose, + }; + }), + ), + ); + + const manifest = { + short_name: "ScrewFast", + name: "ScrewFast", + icons, + display: "minimal-ui", + id: "some-unique-id", + start_url: "/", + theme_color: "#FFEDD5", + background_color: "#262626", + }; + + console.log( + JSON.stringify(manifest, null, 2), + ); + + return new Response(JSON.stringify(manifest)); +};