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

feat: add manifest meta crossorigin attribute #87

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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