mirror of
https://github.com/morten-olsen/morten-olsen.github.io.git
synced 2026-02-08 01:46:28 +01:00
init
This commit is contained in:
39
src/pages/manifest.webmanifest.ts
Normal file
39
src/pages/manifest.webmanifest.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { icons } from '@/assets/images/icons.js';
|
||||
import { data } from '@/data/data.js';
|
||||
import type { ManifestOptions } from 'vite-plugin-pwa';
|
||||
|
||||
export async function GET() {
|
||||
const [maskableIcon] = icons.pngs.filter(
|
||||
(icon) => icon.size === '512x512' && icon.src.includes('png'),
|
||||
);
|
||||
const nonMaskableIcons = icons.pngs.filter((icon) => icon !== maskableIcon);
|
||||
const basics = data.profile.basics;
|
||||
|
||||
const manifest: Partial<ManifestOptions> = {
|
||||
name: basics.name,
|
||||
short_name: basics.name,
|
||||
description: basics.tagline,
|
||||
theme_color: '#30E130',
|
||||
background_color: data.site.theme,
|
||||
start_url: '/',
|
||||
display: 'minimal-ui',
|
||||
icons: [
|
||||
...nonMaskableIcons.map((png) => ({
|
||||
src: png.src,
|
||||
sizes: png.size,
|
||||
type: 'image/png',
|
||||
})),
|
||||
...(maskableIcon
|
||||
? [
|
||||
{
|
||||
src: maskableIcon.src,
|
||||
sizes: maskableIcon.size,
|
||||
type: 'image/png',
|
||||
purpose: 'maskable',
|
||||
},
|
||||
]
|
||||
: []),
|
||||
],
|
||||
};
|
||||
return new Response(JSON.stringify(manifest, null, 2));
|
||||
}
|
||||
Reference in New Issue
Block a user