mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-08-31 23:53:25 +00:00
* Add basic PWA support See: https://github.com/gpxstudio/gpx.studio/issues/38 This will add a basic manifest.json file to the response that creates an installable PWA. It still needs to be internationalized. * Refactor PWA integration and update dependencies - Removed @vite-pwa/sveltekit dependency and related configurations from package.json and vite.config.ts. - Added prebuild script to generate PWA manifest before build. - Moved the manifest link to hooks.server.js and included Apple touch icon. -Added images for various platforms. Images were generated with https://www.pwabuilder.com/imageGenerator * use svg icon, fix urls, and remove generated manifest files --------- Co-authored-by: jonherman <jonherman@gmail.com> Co-authored-by: vcoppe <vianney.coppe@gmail.com>
This commit is contained in:
23
website/src/lib/pwa-manifest.ts
Normal file
23
website/src/lib/pwa-manifest.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import fs from 'fs';
|
||||
import { languages } from '$lib/languages';
|
||||
|
||||
function localizeManifest(manifestTemplateData: any, language: string) {
|
||||
const localizedManifestFile = `static/${language}.manifest.webmanifest`;
|
||||
const localizedStringsFile = `src/locales/${language}.json`;
|
||||
const localizedStrings = JSON.parse(fs.readFileSync(localizedStringsFile, 'utf8'));
|
||||
|
||||
manifestTemplateData.description = localizedStrings.metadata.description;
|
||||
manifestTemplateData.lang = language;
|
||||
manifestTemplateData.start_url = `/${language}/app`;
|
||||
manifestTemplateData.scope = `/${language}/app`;
|
||||
manifestTemplateData.id = `https://gpx.studio/${language}/app`;
|
||||
|
||||
fs.writeFileSync(localizedManifestFile, JSON.stringify(manifestTemplateData, null, 2));
|
||||
}
|
||||
|
||||
const manifestTemplateFile = 'static/en.manifest.webmanifest';
|
||||
const manifestTemplateData = JSON.parse(fs.readFileSync(manifestTemplateFile, 'utf8'));
|
||||
for (const language of Object.keys(languages)) {
|
||||
if (language === 'en') continue;
|
||||
localizeManifest(manifestTemplateData, language);
|
||||
}
|
Reference in New Issue
Block a user