@vigilkids/cms-nuxt 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useAsyncData, useHead,
|
|
1
|
+
import { useAsyncData, useHead, useSeoMeta } from "#imports";
|
|
2
2
|
import { computed, toRef } from "vue";
|
|
3
3
|
import { toArray } from "../utils/list.js";
|
|
4
4
|
import { useCmsClient } from "./useCmsClient.js";
|
|
@@ -38,30 +38,6 @@ export function useArticle(slug) {
|
|
|
38
38
|
return [{ type: "application/ld+json", innerHTML: JSON.stringify(article.value.json_ld) }];
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
|
-
useHead({
|
|
42
|
-
link: () => {
|
|
43
|
-
const a = article.value;
|
|
44
|
-
if (!a?.available_locales || a.available_locales.length <= 1)
|
|
45
|
-
return [];
|
|
46
|
-
const publicConfig = useRuntimeConfig().public;
|
|
47
|
-
const siteUrl = publicConfig.siteUrl ?? "";
|
|
48
|
-
const defaultSlug = a.localized_slugs?.en ?? a.slug;
|
|
49
|
-
const links = a.available_locales.map((locale) => {
|
|
50
|
-
const slug2 = a.localized_slugs?.[locale] ?? a.slug;
|
|
51
|
-
return {
|
|
52
|
-
rel: "alternate",
|
|
53
|
-
hreflang: locale,
|
|
54
|
-
href: locale === "en" ? `${siteUrl}/blog/${slug2}` : `${siteUrl}/${locale}/blog/${slug2}`
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
links.push({
|
|
58
|
-
rel: "alternate",
|
|
59
|
-
hreflang: "x-default",
|
|
60
|
-
href: `${siteUrl}/blog/${defaultSlug}`
|
|
61
|
-
});
|
|
62
|
-
return links;
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
41
|
return {
|
|
66
42
|
article,
|
|
67
43
|
relatedArticles: relatedArticleList,
|
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useHead } from "#imports";
|
|
2
|
+
import { toValue } from "vue";
|
|
3
|
+
export function useHreflangLinks(resource, builder) {
|
|
4
|
+
useHead({
|
|
5
|
+
link: () => {
|
|
6
|
+
const r = toValue(resource);
|
|
7
|
+
const locales = r?.available_locales;
|
|
8
|
+
if (!r || !locales || locales.length === 0) return [];
|
|
9
|
+
const localized = r.localized_slugs ?? {};
|
|
10
|
+
const links = locales.map((locale) => ({
|
|
11
|
+
rel: "alternate",
|
|
12
|
+
hreflang: locale,
|
|
13
|
+
href: builder({
|
|
14
|
+
locale,
|
|
15
|
+
slug: localized[locale] ?? r.slug,
|
|
16
|
+
resource: r
|
|
17
|
+
}),
|
|
18
|
+
key: `cms-hreflang-${locale}`
|
|
19
|
+
}));
|
|
20
|
+
const defaultSlug = localized.en ?? localized[locales[0]] ?? r.slug;
|
|
21
|
+
links.push({
|
|
22
|
+
rel: "alternate",
|
|
23
|
+
hreflang: "x-default",
|
|
24
|
+
href: builder({ locale: "x-default", slug: defaultSlug, resource: r }),
|
|
25
|
+
key: "cms-hreflang-x-default"
|
|
26
|
+
});
|
|
27
|
+
return links;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|