Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Commit

Permalink
feat(meta): add manifest meta crossorigin attribute (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan-T authored Jan 12, 2023
1 parent 1f318d8 commit 7e2f3c6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/parts/manifest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ export default (pwa: PWAContext) => {
return

const nuxt = useNuxt()
const { crossorigin, ...manifest } = pwa.manifest

nuxt.options.runtimeConfig.public.pwaManifest = pwa.manifest
nuxt.options.runtimeConfig.public.pwaManifest = manifest

if (nuxt.options.ssr) {
addServerHandler({
Expand All @@ -20,7 +21,7 @@ export default (pwa: PWAContext) => {
else {
addTemplate({
filename: 'manifest.json',
getContents: () => JSON.stringify(pwa.manifest),
getContents: () => JSON.stringify(manifest),
dst: join(pwa._buildDir, 'manifest.json'),
write: true,
})
Expand All @@ -29,5 +30,6 @@ export default (pwa: PWAContext) => {
pwa._manifestMeta = {
rel: 'manifest',
href: joinURL(nuxt.options.app.baseURL, 'manifest.json'),
crossorigin,
}
}
5 changes: 5 additions & 0 deletions src/parts/manifest/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,9 @@ export interface ManifestOptions {
prefer_related_applications?: boolean
share_target?: ManifestShareTarget
protocol_handlers?: ManifestProtocolHandler[]
/**
* Set meta crossorigin attribute
* @see https://web.dev/add-manifest/#link-manifest
*/
crossorigin?: string
}
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface PWAOptions {
export interface PWAContext extends PWAOptions {
_buildDir: string
_buildAssetsDir: string
_manifestMeta?: { rel: 'manifest'; href: string }
_manifestMeta?: { rel: 'manifest'; href: string; crossorigin?: string }
_splashMetas?: Array<{ rel: 'apple-touch-startup-image'; href: string; media: string }>
_resolver: Resolver
}
Expand Down

0 comments on commit 7e2f3c6

Please sign in to comment.