-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: use
@vite-pwa/vitepress
(#2684)
* docs: use `@vite-pwa/vitepress` * chore: update vite-pwa/vitepress version
- Loading branch information
Showing
10 changed files
with
148 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ node_modules | |
*.d.ts | ||
coverage | ||
!.vitepress | ||
docs/.vitepress/cache/deps/*.* | ||
test/core/src/self |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { | ||
githubusercontentRegex, | ||
pwaFontStylesRegex, | ||
pwaFontsRegex, | ||
vitestDescription, | ||
vitestName, | ||
vitestShortName, | ||
} from '../meta' | ||
|
||
export const pwa = { | ||
outDir: '.vitepress/dist', | ||
registerType: 'autoUpdate', | ||
// include all static assets under public/ | ||
manifest: { | ||
id: '/', | ||
name: vitestName, | ||
short_name: vitestShortName, | ||
description: vitestDescription, | ||
theme_color: '#ffffff', | ||
icons: [ | ||
{ | ||
src: 'pwa-192x192.png', | ||
sizes: '192x192', | ||
type: 'image/png', | ||
}, | ||
{ | ||
src: 'pwa-512x512.png', | ||
sizes: '512x512', | ||
type: 'image/png', | ||
}, | ||
{ | ||
src: 'logo.svg', | ||
sizes: '165x165', | ||
type: 'image/svg', | ||
purpose: 'any maskable', | ||
}, | ||
], | ||
}, | ||
workbox: { | ||
navigateFallbackDenylist: [/^\/new$/], | ||
globPatterns: ['**/*.{css,js,html,png,svg,ico,txt,woff2}'], | ||
runtimeCaching: [ | ||
{ | ||
urlPattern: pwaFontsRegex, | ||
handler: 'CacheFirst', | ||
options: { | ||
cacheName: 'google-fonts-cache', | ||
expiration: { | ||
maxEntries: 10, | ||
maxAgeSeconds: 60 * 60 * 24 * 365, // <== 365 days | ||
}, | ||
cacheableResponse: { | ||
statuses: [0, 200], | ||
}, | ||
}, | ||
}, | ||
{ | ||
urlPattern: pwaFontStylesRegex, | ||
handler: 'CacheFirst', | ||
options: { | ||
cacheName: 'gstatic-fonts-cache', | ||
expiration: { | ||
maxEntries: 10, | ||
maxAgeSeconds: 60 * 60 * 24 * 365, // <== 365 days | ||
}, | ||
cacheableResponse: { | ||
statuses: [0, 200], | ||
}, | ||
}, | ||
}, | ||
{ | ||
urlPattern: githubusercontentRegex, | ||
handler: 'CacheFirst', | ||
options: { | ||
cacheName: 'githubusercontent-images-cache', | ||
expiration: { | ||
maxEntries: 10, | ||
maxAgeSeconds: 60 * 60 * 24 * 365, // <== 365 days | ||
}, | ||
cacheableResponse: { | ||
statuses: [0, 200], | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { HeadConfig, TransformContext } from 'vitepress' | ||
|
||
import { preconnectHomeLinks, preconnectLinks } from '../meta' | ||
|
||
export const transformHead = async ({ pageData }: TransformContext): Promise<HeadConfig[]> => { | ||
const head: HeadConfig[] = [] | ||
|
||
const home = pageData.relativePath === 'index.md' | ||
|
||
;(home ? preconnectHomeLinks : preconnectLinks).forEach((link) => { | ||
head.push(['link', { rel: 'dns-prefetch', href: link }]) | ||
head.push(['link', { rel: 'preconnect', href: link }]) | ||
}) | ||
|
||
head.push(['link', { rel: 'prefetch', href: '/logo.svg' }]) | ||
if (home) | ||
head.push(['link', { rel: 'prefetch', href: '/netlify.svg' }]) | ||
|
||
return head | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.