-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(i18n); add i18n aware vue components, with localized manifest
- Loading branch information
Antoine Monnet
committed
Jan 18, 2025
1 parent
c5465e7
commit 272c836
Showing
3 changed files
with
85 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import type { MetaObject } from '@nuxt/schema' | ||
import { defineComponent, ref } from 'vue' | ||
import { pwaInfo } from 'virtual:pwa-info' | ||
import { pwaAssetsHead } from 'virtual:pwa-assets/head' | ||
import { useHead, useLocalePath } from '#imports' | ||
|
||
export default defineComponent({ | ||
setup() { | ||
const meta = ref<MetaObject>({ link: [] }) | ||
const localePath = useLocalePath() | ||
useHead(meta) | ||
if (pwaAssetsHead.themeColor) | ||
meta.value.meta = [{ name: 'theme-color', content: pwaAssetsHead.themeColor.content }] | ||
|
||
if (pwaAssetsHead.links.length) | ||
// @ts-expect-error: links are fine | ||
meta.value.link!.push(...pwaAssetsHead.links) | ||
|
||
if (pwaInfo) { | ||
const { webManifest } = pwaInfo | ||
if (webManifest) { | ||
const { href, useCredentials } = webManifest | ||
const prefix = localePath("/").replace("^/$","") | ||
if (useCredentials) { | ||
meta.value.link!.push({ | ||
rel: 'manifest', | ||
href: prefix+href, | ||
crossorigin: 'use-credentials', | ||
}) | ||
} | ||
else { | ||
meta.value.link!.push({ | ||
rel: 'manifest', | ||
href: prefix+href, | ||
}) | ||
} | ||
} | ||
} | ||
|
||
return () => null | ||
}, | ||
}) |
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,35 @@ | ||
import type { MetaObject } from '@nuxt/schema' | ||
import { defineComponent, ref } from 'vue' | ||
import { pwaInfo } from 'virtual:pwa-info' | ||
import { useHead, useLocalePath } from '#imports' | ||
|
||
export default defineComponent({ | ||
async setup() { | ||
if (pwaInfo) { | ||
const meta = ref<MetaObject>({ link: [] }) | ||
const localePath = useLocalePath() | ||
useHead(meta) | ||
|
||
const { webManifest } = pwaInfo | ||
if (webManifest) { | ||
const { href, useCredentials } = webManifest | ||
const prefix = localePath("/").replace("^/$","") | ||
if (useCredentials) { | ||
meta.value.link!.push({ | ||
rel: 'manifest', | ||
href: prefix+href, | ||
crossorigin: 'use-credentials', | ||
}) | ||
} | ||
else { | ||
meta.value.link!.push({ | ||
rel: 'manifest', | ||
href: prefix+href, | ||
}) | ||
} | ||
} | ||
} | ||
|
||
return () => null | ||
}, | ||
}) |
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