feat: Making Quartz available offline by making it a PWA (#465)
* Adding PWA and chaching for offline aviability * renamed workbox config to fit Quartz' scheme * Documenting new configuration * Added missig umami documentation * Fixed formatting so the build passes, thank you prettier :) * specified caching strategies to improve performance * formatting... * fixing "404 manifest.json not found" on subdirectories by adding a / to manifestpath * turning it into a plugin * Removed Workbox-cli and updated @types/node * Added Serviceworkercode to offline.ts * formatting * Removing workbox from docs * applied suggestions * Removed path.join for sw path Co-authored-by: Jacky Zhao <j.zhao2k19@gmail.com> * Removed path.join for manifest path Co-authored-by: Jacky Zhao <j.zhao2k19@gmail.com> * Removing path module import * Added absolute path to manifests start_url and manifest "import" using baseUrl * Adding protocol to baseurl Co-authored-by: Jacky Zhao <j.zhao2k19@gmail.com> * Adding protocol to start_url too then * formatting... * Adding fallback page * Documenting offline plugin * formatting... * merge suggestion Co-authored-by: Jacky Zhao <j.zhao2k19@gmail.com> * merge suggestion Co-authored-by: Jacky Zhao <j.zhao2k19@gmail.com> * merge suggestion Co-authored-by: Jacky Zhao <j.zhao2k19@gmail.com> * merge suggestion Co-authored-by: Jacky Zhao <j.zhao2k19@gmail.com> * merge suggestion Co-authored-by: Jacky Zhao <j.zhao2k19@gmail.com> * merge suggestion Co-authored-by: Jacky Zhao <j.zhao2k19@gmail.com> * merge suggestion Co-authored-by: Jacky Zhao <j.zhao2k19@gmail.com> * merge suggestion Co-authored-by: Jacky Zhao <j.zhao2k19@gmail.com> * merge suggestion Co-authored-by: Jacky Zhao <j.zhao2k19@gmail.com> * merge suggestion Co-authored-by: Jacky Zhao <j.zhao2k19@gmail.com> * merge suggestion Co-authored-by: Jacky Zhao <j.zhao2k19@gmail.com> * merge suggestion Co-authored-by: Jacky Zhao <j.zhao2k19@gmail.com> * formatting... * Fixing manifest path, all these nits hiding the actual issues .-. * Offline fallback page through plugins, most things taken from 404 Plugin * adding Offline Plugin to config * formatting... * Turned offline off as default and removed offline.md --------- Co-authored-by: Jacky Zhao <j.zhao2k19@gmail.com>
This commit is contained in:
		
							parent
							
								
									27a6087dd5
								
							
						
					
					
						commit
						d6301fae90
					
				
					 13 changed files with 235 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -14,6 +14,8 @@ export default (() => {
 | 
			
		|||
 | 
			
		||||
    const iconPath = joinSegments(baseDir, "static/icon.png")
 | 
			
		||||
    const ogImagePath = `https://${cfg.baseUrl}/static/og-image.png`
 | 
			
		||||
    const manifest =
 | 
			
		||||
      cfg.baseUrl == undefined ? "/manifest.json" : `https://${cfg.baseUrl}/manifest.json`
 | 
			
		||||
 | 
			
		||||
    return (
 | 
			
		||||
      <head>
 | 
			
		||||
| 
						 | 
				
			
			@ -25,7 +27,9 @@ export default (() => {
 | 
			
		|||
        {cfg.baseUrl && <meta property="og:image" content={ogImagePath} />}
 | 
			
		||||
        <meta property="og:width" content="1200" />
 | 
			
		||||
        <meta property="og:height" content="675" />
 | 
			
		||||
        <meta name="theme-color" content="#faf8f8" />
 | 
			
		||||
        <link rel="icon" href={iconPath} />
 | 
			
		||||
        <link rel="manifest" href={manifest} />
 | 
			
		||||
        <meta name="description" content={description} />
 | 
			
		||||
        <meta name="generator" content="Quartz" />
 | 
			
		||||
        <link rel="preconnect" href="https://fonts.googleapis.com" />
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										12
									
								
								quartz/components/pages/OfflineFallbackPage.tsx
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								quartz/components/pages/OfflineFallbackPage.tsx
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,12 @@
 | 
			
		|||
import { QuartzComponentConstructor } from "../types"
 | 
			
		||||
 | 
			
		||||
function OfflineFallbackPage() {
 | 
			
		||||
  return (
 | 
			
		||||
    <article class="popover-hint">
 | 
			
		||||
      <h1>Offline</h1>
 | 
			
		||||
      <p>This page isn't offline available yet.</p>
 | 
			
		||||
    </article>
 | 
			
		||||
  )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default (() => OfflineFallbackPage) satisfies QuartzComponentConstructor
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue