N-FIN-57: add serwist and PWA configuration

This commit is contained in:
Markus Thielker 2024-03-17 20:28:41 +01:00
parent 609e0056da
commit a7863d4b31
No known key found for this signature in database
8 changed files with 1365 additions and 49 deletions

View file

@ -1,4 +1,4 @@
import type { Metadata } from 'next';
import type { Viewport } from 'next';
import { Inter } from 'next/font/google';
import './globals.css';
import { cn } from '@/lib/utils';
@ -8,9 +8,31 @@ import Navigation from '@/components/navigation';
const inter = Inter({subsets: ['latin']});
export const metadata: Metadata = {
title: 'Finances',
description: 'Track your finances with ease',
const APP_NAME = 'Finances';
const APP_DEFAULT_TITLE = 'Finances';
const APP_TITLE_TEMPLATE = `%s | ${APP_DEFAULT_TITLE}`;
const APP_DESCRIPTION = 'Track your finances with ease';
export const metadata = {
applicationName: APP_NAME,
title: {
default: APP_DEFAULT_TITLE,
template: APP_TITLE_TEMPLATE,
},
description: APP_DESCRIPTION,
appleWebApp: {
capable: true,
statusBarStyle: 'default',
title: APP_DEFAULT_TITLE,
},
formatDetection: {
telephone: false,
},
};
export const viewport: Viewport = {
themeColor: '#0B0908',
width: 'device-width',
};
export default function RootLayout({
@ -20,6 +42,13 @@ export default function RootLayout({
}>) {
return (
<html lang="en">
<head>
<link crossOrigin="use-credentials" rel="manifest" href="/manifest.json"/>
<link
rel="icon"
href="/logo_white.png"
/>
</head>
<body className={cn('dark', inter.className)}>
<Navigation/>
<main className="p-4 sm:p-8">

15
src/app/service-worker.ts Normal file
View file

@ -0,0 +1,15 @@
import { defaultCache } from '@serwist/next/browser';
import type { PrecacheEntry } from '@serwist/precaching';
import { installSerwist } from '@serwist/sw';
declare const self: ServiceWorkerGlobalScope & {
__SW_MANIFEST: (PrecacheEntry | string)[] | undefined;
};
installSerwist({
precacheEntries: self.__SW_MANIFEST,
skipWaiting: true,
clientsClaim: true,
navigationPreload: true,
runtimeCaching: defaultCache,
});