Skip to content

Commit a2bab40

Browse files
committed
feat: i18n seo
1 parent 3a14fc7 commit a2bab40

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

app.vue

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
<template>
22
<!-- Google Font -->
33
<Html :lang="head.htmlAttrs.lang" :dir="head.htmlAttrs.dir">
4+
<Head>
5+
<template v-for="link in head.link" :key="link.hid">
6+
<Link
7+
:id="link.hid"
8+
:rel="link.rel"
9+
:href="link.href"
10+
:hreflang="link.hreflang"
11+
/>
12+
</template>
13+
</Head>
14+
415
<ClientOnly>
516
<NuxtLoadingIndicator :color="isDark ? '#C2C8EC' : '#2F45C7'" />
617
</ClientOnly>
@@ -27,31 +38,9 @@ const router = useRouter();
2738
const { locale, availableLocales } = useI18n();
2839
const lang = ref(route.query.lang as string);
2940
30-
// check if lang query param is valid
31-
if (lang.value && availableLocales.includes(lang.value)) {
32-
locale.value = lang.value;
33-
34-
// remove lang query param from url
35-
const newQuery = { ...route.query };
36-
delete newQuery.lang;
37-
router.replace({ query: newQuery });
38-
}
39-
4041
const head = useLocaleHead({
4142
addDirAttribute: true,
4243
identifierAttribute: "id",
4344
addSeoAttributes: true,
4445
});
45-
46-
onMounted(() => {
47-
const links = availableLocales.map((l) => ({
48-
rel: "alternate",
49-
hreflang: l,
50-
href: `http://bluescript.app${route.fullPath.split("?")[0]}?lang=${l}`,
51-
}));
52-
53-
useHead({
54-
link: links,
55-
});
56-
});
5746
</script>

0 commit comments

Comments
 (0)