feat: add PWA support
This commit is contained in:
parent
9590e739b0
commit
e72c80197b
1 changed files with 34 additions and 0 deletions
34
src/pages/manifest.json.js
Normal file
34
src/pages/manifest.json.js
Normal file
|
@ -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))
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue