From 5a7c4df70a79901437b3045fe596f00d6759085c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thea=20Sch=C3=B6bl?= Date: Thu, 6 Jul 2023 00:24:33 +0200 Subject: [PATCH] pwa adjustments --- src/routes/+layout.svelte | 17 +++++++++++++---- src/routes/config/+layout.svelte | 23 ++++++++++++----------- static/.htaccess | 10 +++++++--- vite.config.js | 17 ++++++++++++++++- 4 files changed, 48 insertions(+), 19 deletions(-) diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index dff7dd07..184d8e71 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -2,16 +2,22 @@ import "$lib/style/fonts/noto-sans-mono.scss" import "$lib/style/fonts/material-symbols-rounded.scss" import {onMount} from "svelte" - import {applyTheme, argbFromHex, themeFromSourceColor} from "@material/material-color-utilities" + import { + applyTheme, + argbFromHex, + hexFromArgb, + themeFromSourceColor, + } from "@material/material-color-utilities" import Navigation from "$lib/components/Navigation.svelte" import {hasSerialPermission} from "$lib/serial/device.js" import {initSerial} from "$lib/serial/connection.js" import {pwaInfo} from "virtual:pwa-info" + const theme = themeFromSourceColor(argbFromHex("#6D81C7"), [ + {name: "success", value: argbFromHex("#00ff00"), blend: true}, + ]) + onMount(async () => { - const theme = themeFromSourceColor(argbFromHex("#6D81C7"), [ - {name: "success", value: argbFromHex("#00ff00"), blend: true}, - ]) const dark = true // window.matchMedia("(prefers-color-scheme: dark)").matches applyTheme(theme, {target: document.body, dark}) @@ -38,6 +44,9 @@ {@html webManifestLink} + dot i/o + + diff --git a/src/routes/config/+layout.svelte b/src/routes/config/+layout.svelte index 4305d784..80309f95 100644 --- a/src/routes/config/+layout.svelte +++ b/src/routes/config/+layout.svelte @@ -1,19 +1,20 @@ diff --git a/static/.htaccess b/static/.htaccess index 1a649181..a5e389bf 100644 --- a/static/.htaccess +++ b/static/.htaccess @@ -4,6 +4,10 @@ RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L] +# remove trailing slash +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^(.*)/$ /$1 [L,R] # R=301 + # SPA mode RewriteBase / RewriteRule ^200\.html$ - [L] @@ -11,6 +15,6 @@ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /200.html [L] -# remove trailing slash -RewriteCond %{REQUEST_FILENAME} !-d -RewriteRule ^(.*)/$ /$1 [L,R=301] +# redirect not found urls to .html files +RewriteCond %{REQUEST_FILENAME} !-f +RewriteRule ^([^./]+)/?$ $1.html [QSA] diff --git a/vite.config.js b/vite.config.js index 63f92879..80a9f83d 100644 --- a/vite.config.js +++ b/vite.config.js @@ -3,5 +3,20 @@ import {defineConfig} from "vite" import {SvelteKitPWA} from "@vite-pwa/sveltekit" export default defineConfig({ - plugins: [sveltekit(), SvelteKitPWA()], + plugins: [ + sveltekit(), + SvelteKitPWA({ + kit: { + adapterFallback: "/200.html", + trailingSlash: "never", + }, + base: "/", + workbox: { + modifyURLPrefix: { + "": "/", + "./": "/", + }, + }, + }), + ], })