File tree Expand file tree Collapse file tree 6 files changed +74
-0
lines changed Expand file tree Collapse file tree 6 files changed +74
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { Footer } from '@/components/footer';
7
7
import { CSPostHogProvider } from '@/components/providers' ;
8
8
import thumbnail from '../public/thumbnail.jpg' ;
9
9
import ExerciseNavbar from '@/components/mobile/exerciseNavbar' ;
10
+ import RegisterSW from '@/components/providers/service-worker' ;
10
11
11
12
const robotoFlex = Roboto_Flex ( {
12
13
subsets : [ 'latin' ] ,
@@ -16,6 +17,7 @@ const robotoFlex = Roboto_Flex({
16
17
17
18
export const metadata : Metadata = {
18
19
metadataBase : new URL ( 'https://logicola.org' ) ,
20
+ themeColor : '#ffffff' ,
19
21
title : 'Logicola' ,
20
22
description :
21
23
'LogiCola is a program to help students learn logic. This is a web version of the original software built by the late Professor Harry Gensler.' ,
@@ -58,6 +60,10 @@ export default function RootLayout({
58
60
} > ) {
59
61
return (
60
62
< html lang = 'en' >
63
+ < head >
64
+ < meta name = 'theme-color' content = '#FFFFFF' />
65
+ < link rel = 'manifest' href = '/manifest.json' />
66
+ </ head >
61
67
< CSPostHogProvider >
62
68
< body
63
69
className = { `antialiased min-h-screen bg-white text-primaryColor ${ robotoFlex . className } ` }
@@ -67,6 +73,7 @@ export default function RootLayout({
67
73
68
74
< Navbar />
69
75
< main className = { `flex` } > { children } </ main >
76
+ < RegisterSW />
70
77
< Footer />
71
78
</ body >
72
79
</ CSPostHogProvider >
Original file line number Diff line number Diff line change
1
+ // You could create a new component like RegisterSW.tsx
2
+ 'use client' ;
3
+ import { useEffect } from 'react' ;
4
+
5
+ export default function RegisterSW ( ) {
6
+ useEffect ( ( ) => {
7
+ if ( 'serviceWorker' in navigator ) {
8
+ navigator . serviceWorker
9
+ . register ( '/sw.js' )
10
+ . then ( ( registration ) => console . log ( 'SW registered:' , registration ) )
11
+ . catch ( ( error ) => console . log ( 'SW registration failed:' , error ) ) ;
12
+ }
13
+ } , [ ] ) ;
14
+
15
+ return null ;
16
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " LogiCola" ,
3
+ "short_name" : " LogiCola" ,
4
+ "description" : " LogiCola helps you learn logic." ,
5
+ "start_url" : " /" ,
6
+ "display" : " standalone" ,
7
+ "background_color" : " #ffffff" ,
8
+ "theme_color" : " #ffffff" ,
9
+ "orientation" : " portrait" ,
10
+ "icons" : [
11
+ {
12
+ "src" : " /icon-192.png" ,
13
+ "sizes" : " 192x192" ,
14
+ "type" : " image/png" ,
15
+ "purpose" : " any maskable"
16
+ },
17
+ {
18
+ "src" : " /icon-512.png" ,
19
+ "sizes" : " 512x512" ,
20
+ "type" : " image/png"
21
+ }
22
+ ]
23
+ }
Original file line number Diff line number Diff line change
1
+ const CACHE_NAME = 'logicola-cache-v1' ;
2
+ const urlsToCache = [
3
+ '/' ,
4
+ '/manifest.json' ,
5
+ '/icon.svg' ,
6
+ // Add other static assets like
7
+ '/globals.css' ,
8
+ // Add any other pages/routes you want to cache
9
+ ] ;
10
+
11
+ self . addEventListener ( 'install' , ( event ) => {
12
+ event . waitUntil (
13
+ caches . open ( CACHE_NAME )
14
+ . then ( ( cache ) => {
15
+ return cache . addAll ( urlsToCache ) ;
16
+ } )
17
+ ) ;
18
+ } ) ;
19
+
20
+ self . addEventListener ( 'fetch' , ( event ) => {
21
+ event . respondWith (
22
+ caches . match ( event . request )
23
+ . then ( ( response ) => {
24
+ // Return cached version or fetch from network
25
+ return response || fetch ( event . request ) ;
26
+ } )
27
+ ) ;
28
+ } ) ;
You can’t perform that action at this time.
0 commit comments