feat(pwa): ✨ add service worker registration
This commit is contained in:
parent
1e2630988f
commit
c2477e0ff5
7
islands/RegisterServiceWorker.tsx
Normal file
7
islands/RegisterServiceWorker.tsx
Normal file
|
@ -0,0 +1,7 @@
|
|||
export default function RegisterServiceWorker({ href }: { href: string }) {
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.register(href)
|
||||
}
|
||||
|
||||
return <></>
|
||||
}
|
|
@ -2,6 +2,7 @@ import { asset, Head, Partial } from '$fresh/runtime.ts'
|
|||
import { type PageProps } from '$fresh/server.ts'
|
||||
import { Footer } from '../components/Footer.tsx'
|
||||
import { Header } from '../components/Header.tsx'
|
||||
import RegisterServiceWorker from '../islands/RegisterServiceWorker.tsx'
|
||||
|
||||
export default function App({ Component }: PageProps) {
|
||||
return (
|
||||
|
@ -52,6 +53,7 @@ export default function App({ Component }: PageProps) {
|
|||
<Component />
|
||||
</Partial>
|
||||
</main>
|
||||
<RegisterServiceWorker href={asset('/sw.js')} />
|
||||
<Footer />
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue