nuxt-seo-utils 6.0.4 → 6.0.6
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
package/dist/module.mjs
CHANGED
|
@@ -15,20 +15,19 @@ import imageSize from 'image-size';
|
|
|
15
15
|
function extendNuxtConfigAppHeadSeoMeta(nuxt = useNuxt()) {
|
|
16
16
|
const seoMeta = nuxt.options.app?.seoMeta || nuxt.options.app?.head?.seoMeta || false;
|
|
17
17
|
const configSeoMeta = nuxt.options.seo?.meta || false;
|
|
18
|
-
if (!seoMeta)
|
|
18
|
+
if (!seoMeta && !configSeoMeta)
|
|
19
19
|
return;
|
|
20
20
|
nuxt.options.app.head = nuxt.options.app.head || {};
|
|
21
21
|
nuxt.options.app.head = {
|
|
22
22
|
...nuxt.options.app.head,
|
|
23
23
|
meta: [
|
|
24
24
|
...nuxt.options.app.head.meta || [],
|
|
25
|
-
...unpackMeta(seoMeta),
|
|
26
|
-
...unpackMeta(configSeoMeta)
|
|
25
|
+
...unpackMeta(seoMeta || {}),
|
|
26
|
+
...unpackMeta(configSeoMeta || {})
|
|
27
27
|
]
|
|
28
28
|
};
|
|
29
29
|
delete nuxt.options.app.seoMeta;
|
|
30
30
|
delete nuxt.options.app.head.seoMeta;
|
|
31
|
-
return nuxt.options.app.head;
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
function extendTypes(module, template) {
|
|
@@ -51,7 +51,7 @@ export function useBreadcrumbItems(options = {}) {
|
|
|
51
51
|
return segments.filter(Boolean).map((item) => {
|
|
52
52
|
const route = router.resolve(item.to)?.matched?.[0] || router.currentRoute.value;
|
|
53
53
|
const routeMeta = route?.meta || {};
|
|
54
|
-
const routeName = route ? String(route.name?.split("___")) : item.to === "/" ? "index" : null;
|
|
54
|
+
const routeName = route ? String(route.name?.split("___")[0]) : item.to === "/" ? "index" : null;
|
|
55
55
|
const fallbackLabel = titleCase(routeName === "index" ? "Home" : (item.to || "").split("/").pop() || "");
|
|
56
56
|
if (routeMeta.breadcrumb) {
|
|
57
57
|
item = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useHead } from "@unhead/vue";
|
|
2
|
-
import { defineNuxtPlugin, useRoute } from "nuxt/app";
|
|
2
|
+
import { defineNuxtPlugin, useError, useRoute } from "nuxt/app";
|
|
3
3
|
import { titleCase } from "scule";
|
|
4
4
|
import { withoutTrailingSlash } from "ufo";
|
|
5
5
|
import { computed } from "vue";
|
|
@@ -10,7 +10,11 @@ export default defineNuxtPlugin({
|
|
|
10
10
|
},
|
|
11
11
|
setup() {
|
|
12
12
|
const route = useRoute();
|
|
13
|
+
const err = useError();
|
|
13
14
|
const title = computed(() => {
|
|
15
|
+
if ([404, 500].includes(err.value?.statusCode)) {
|
|
16
|
+
return `${err.value.statusCode} - ${err.value.message}`;
|
|
17
|
+
}
|
|
14
18
|
if (typeof route.meta?.title === "string")
|
|
15
19
|
return route.meta?.title;
|
|
16
20
|
const path = withoutTrailingSlash(route.path || "/");
|
|
@@ -2,16 +2,21 @@ import { useSiteConfig } from "#site-config/server/composables/useSiteConfig";
|
|
|
2
2
|
import { defineEventHandler, getRequestHost, sendRedirect, setHeader } from "h3";
|
|
3
3
|
import { joinURL } from "ufo";
|
|
4
4
|
export default defineEventHandler((e) => {
|
|
5
|
+
const path = e.path;
|
|
6
|
+
if (path.startsWith("/_nuxt") || path.startsWith("/api")) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
5
9
|
const siteConfig = useSiteConfig(e);
|
|
6
|
-
if (siteConfig.url) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
if (!siteConfig.url) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const siteConfigHostName = new URL(e.path, siteConfig.url).host;
|
|
14
|
+
const host = getRequestHost(e, { xForwardedHost: true });
|
|
15
|
+
if (e.headers.get("x-nuxt-seo-redirected")) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (host.split(":")[0] !== siteConfigHostName.split(":")[0]) {
|
|
19
|
+
setHeader(e, "x-nuxt-seo-redirected", "true");
|
|
20
|
+
return sendRedirect(e, joinURL(siteConfig.url, e.path), 301);
|
|
16
21
|
}
|
|
17
22
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-seo-utils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.0.
|
|
4
|
+
"version": "6.0.6",
|
|
5
5
|
"description": "SEO utilities to improve your Nuxt sites discoverability and shareability",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://github.com/sponsors/harlan-zw",
|
|
@@ -32,38 +32,38 @@
|
|
|
32
32
|
]
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@nuxt/kit": "^3.
|
|
36
|
-
"@unhead/addons": "^1.11.
|
|
37
|
-
"@unhead/schema": "^1.11.
|
|
35
|
+
"@nuxt/kit": "^3.15.1",
|
|
36
|
+
"@unhead/addons": "^1.11.16",
|
|
37
|
+
"@unhead/schema": "^1.11.16",
|
|
38
38
|
"defu": "^6.1.4",
|
|
39
39
|
"escape-string-regexp": "^5.0.0",
|
|
40
|
-
"fast-glob": "^3.3.
|
|
41
|
-
"image-size": "^1.
|
|
42
|
-
"mlly": "^1.7.
|
|
43
|
-
"nuxt-site-config": "^3.0.
|
|
44
|
-
"pathe": "^
|
|
40
|
+
"fast-glob": "^3.3.3",
|
|
41
|
+
"image-size": "^1.2.0",
|
|
42
|
+
"mlly": "^1.7.4",
|
|
43
|
+
"nuxt-site-config": "^3.0.6",
|
|
44
|
+
"pathe": "^2.0.1",
|
|
45
45
|
"scule": "^1.3.0",
|
|
46
46
|
"ufo": "^1.5.4"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@antfu/eslint-config": "3.11.2",
|
|
50
50
|
"@nuxt/module-builder": "^0.8.4",
|
|
51
|
-
"@nuxt/test-utils": "^3.15.
|
|
52
|
-
"@nuxt/ui": "^2.
|
|
51
|
+
"@nuxt/test-utils": "^3.15.4",
|
|
52
|
+
"@nuxt/ui": "^2.20.0",
|
|
53
53
|
"@nuxtjs/eslint-config-typescript": "^12.1.0",
|
|
54
54
|
"@nuxtjs/i18n": "^9.1.1",
|
|
55
|
-
"@unhead/shared": "^1.11.
|
|
55
|
+
"@unhead/shared": "^1.11.16",
|
|
56
56
|
"@vue/test-utils": "^2.4.6",
|
|
57
|
-
"bumpp": "^9.
|
|
57
|
+
"bumpp": "^9.10.0",
|
|
58
58
|
"case-police": "^0.7.2",
|
|
59
59
|
"cheerio": "1.0.0",
|
|
60
|
-
"eslint": "^9.
|
|
61
|
-
"happy-dom": "^
|
|
60
|
+
"eslint": "^9.18.0",
|
|
61
|
+
"happy-dom": "^16.5.3",
|
|
62
62
|
"markdownlint-cli": "^0.43.0",
|
|
63
|
-
"nuxt": "^3.
|
|
63
|
+
"nuxt": "^3.15.1",
|
|
64
64
|
"nuxt-content-twoslash": "^0.1.2",
|
|
65
|
-
"playwright-core": "^1.49.
|
|
66
|
-
"sass": "^1.
|
|
65
|
+
"playwright-core": "^1.49.1",
|
|
66
|
+
"sass": "^1.83.3",
|
|
67
67
|
"typescript": "5.6.3",
|
|
68
68
|
"vitest": "^2.1.8"
|
|
69
69
|
},
|