fix: 🩹 version manifest assets based on instance version

This commit is contained in:
ThatOneCalculator 2023-07-20 23:31:51 -07:00
parent 03077a157e
commit 8de79198a1
No known key found for this signature in database
GPG Key ID: 8703CACD01000000
2 changed files with 13 additions and 7 deletions

View File

@ -9,25 +9,25 @@
"orientation": "portrait-primary",
"icons": [
{
"src": "/static-assets/icons/192.png?v=2",
"src": "/static-assets/icons/192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "any"
},
{
"src": "/static-assets/icons/512.png?v=2",
"src": "/static-assets/icons/512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "any"
},
{
"src": "/static-assets/icons/maskable.png?v=2",
"src": "/static-assets/icons/maskable.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "/static-assets/icons/monochrome.png?v=2",
"src": "/static-assets/icons/monochrome.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "monochrome"
@ -43,14 +43,14 @@
},
"screenshots": [
{
"src": "/static-assets/screenshots/1.webp?v=2",
"src": "/static-assets/screenshots/1.webp",
"sizes": "1080x2340",
"type": "image/webp",
"platform": "narrow",
"label": "Profile page"
},
{
"src": "/static-assets/screenshots/2.webp?v=2",
"src": "/static-assets/screenshots/2.webp",
"sizes": "1080x2340",
"type": "image/webp",
"platform": "narrow",

View File

@ -1,5 +1,6 @@
import type Koa from "koa";
import { fetchMeta } from "@/misc/fetch-meta.js";
import config from "@/config/index.js";
import manifest from "./manifest.json" assert { type: "json" };
export const manifestHandler = async (ctx: Koa.Context) => {
@ -12,7 +13,12 @@ export const manifestHandler = async (ctx: Koa.Context) => {
res.short_name = instance.name || "Firefish";
res.name = instance.name || "Firefish";
if (instance.themeColor) res.theme_color = instance.themeColor;
for (const icon of res.icons) {
icon.src = `${icon.src}?v=${config.version.replace(/[^0-9]/g, '')}`;
}
for (const screenshot of res.screenshots) {
screenshot.src = `${screenshot.src}?v=${config.version.replace(/[^0-9]/g, '')}`;
}
ctx.set("Cache-Control", "max-age=300");
ctx.body = res;
};