nuxt-seo-utils 7.0.12 → 7.0.13
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
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { useNuxt,
|
|
1
|
+
import { useNuxt, addTypeTemplate, defineNuxtModule, useLogger, createResolver, addServerHandler, hasNuxtModule, addPlugin, addImports, addVitePlugin } from '@nuxt/kit';
|
|
2
2
|
import UnheadVite from '@unhead/addons/vite';
|
|
3
3
|
import { defu } from 'defu';
|
|
4
4
|
import { installNuxtSiteConfig } from 'nuxt-site-config/kit';
|
|
5
|
+
import { resolve, relative, extname, dirname, basename } from 'pathe';
|
|
5
6
|
import { unpackMeta } from '@unhead/vue/utils';
|
|
6
7
|
import fg from 'fast-glob';
|
|
7
|
-
import { relative, resolve, extname, dirname, basename } from 'pathe';
|
|
8
8
|
import fs from 'node:fs';
|
|
9
9
|
import { encodePath, joinURL } from 'ufo';
|
|
10
10
|
import escapeRE from 'escape-string-regexp';
|
|
@@ -30,30 +30,13 @@ function extendNuxtConfigAppHeadSeoMeta(nuxt = useNuxt()) {
|
|
|
30
30
|
delete nuxt.options.app.head.seoMeta;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
function extendTypes(module, template) {
|
|
34
|
-
const nuxt = useNuxt();
|
|
35
|
-
const { resolve } = createResolver(import.meta.url);
|
|
36
|
-
addTemplate({
|
|
37
|
-
filename: `module/${module}.d.ts`,
|
|
38
|
-
getContents: async () => {
|
|
39
|
-
const typesPath = relative(resolve(nuxt.options.rootDir, nuxt.options.buildDir, "module"), resolve("runtime/types"));
|
|
40
|
-
const s = await template({ typesPath });
|
|
41
|
-
return `// Generated by ${module}
|
|
42
|
-
${s}
|
|
43
|
-
export {}
|
|
44
|
-
`;
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
nuxt.hooks.hook("prepare:types", ({ references }) => {
|
|
48
|
-
references.push({ path: resolve(nuxt.options.buildDir, `module/${module}.d.ts`) });
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
33
|
function extendNuxtConfigAppHeadTypes(nuxt = useNuxt()) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
34
|
+
addTypeTemplate({
|
|
35
|
+
filename: "module/nuxt-seo-utils.assets.d.ts",
|
|
36
|
+
getContents: async () => {
|
|
37
|
+
const paths = (await fg(["**/*"], { cwd: resolve(nuxt.options.srcDir, "public") })).map((p) => `/${p}`);
|
|
38
|
+
const jsPaths = paths.filter((p) => p.endsWith(".js") || p.endsWith(".mjs"));
|
|
39
|
+
return `// Generated by nuxt-seo-utils
|
|
57
40
|
declare module '#app' {
|
|
58
41
|
import { HeadEntry, HeadTag } from '@unhead/vue/types'
|
|
59
42
|
|
|
@@ -75,7 +58,13 @@ declare module '@unhead/schema' {
|
|
|
75
58
|
src: JsFiles
|
|
76
59
|
}
|
|
77
60
|
}
|
|
78
|
-
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export {}
|
|
64
|
+
`;
|
|
65
|
+
}
|
|
66
|
+
}, {
|
|
67
|
+
nuxt: true
|
|
79
68
|
});
|
|
80
69
|
}
|
|
81
70
|
|
|
@@ -102,7 +91,7 @@ function generateNuxtPageFromFile(file, pagesDir) {
|
|
|
102
91
|
};
|
|
103
92
|
let parent = [];
|
|
104
93
|
for (let i = 0; i < segments.length; i++) {
|
|
105
|
-
const segment = segments[i];
|
|
94
|
+
const segment = segments[i] || "";
|
|
106
95
|
const tokens = parseSegment(segment);
|
|
107
96
|
const segmentName = tokens.map(({ value }) => value).join("");
|
|
108
97
|
route.name += (route.name && "-") + segmentName;
|
|
@@ -143,7 +132,7 @@ function parseSegment(segment) {
|
|
|
143
132
|
buffer = "";
|
|
144
133
|
}
|
|
145
134
|
while (i < segment.length) {
|
|
146
|
-
const c = segment[i];
|
|
135
|
+
const c = segment[i] || "";
|
|
147
136
|
switch (state) {
|
|
148
137
|
case 0 /* initial */:
|
|
149
138
|
buffer = "";
|
|
@@ -241,7 +230,7 @@ async function generateTagsFromPageDirImages(nuxt = useNuxt()) {
|
|
|
241
230
|
const nitroOutputMap = [];
|
|
242
231
|
for (const file of files) {
|
|
243
232
|
const fileName = basename(file);
|
|
244
|
-
const keyword = fileName.split(".")[0];
|
|
233
|
+
const keyword = fileName.split(".")[0] || "";
|
|
245
234
|
let { path } = generateNuxtPageFromFile(resolve(pagesDir, dirname(file)), pagesDir);
|
|
246
235
|
const meta = await getImageMeta(pagesDir, file);
|
|
247
236
|
if (path.endsWith("/_dir"))
|
|
@@ -393,8 +382,7 @@ const module = defineNuxtModule({
|
|
|
393
382
|
name: "nuxt-seo-utils",
|
|
394
383
|
configKey: "seo",
|
|
395
384
|
compatibility: {
|
|
396
|
-
nuxt: ">=3.16.0"
|
|
397
|
-
bridge: false
|
|
385
|
+
nuxt: ">=3.16.0"
|
|
398
386
|
}
|
|
399
387
|
},
|
|
400
388
|
defaults: {
|
|
@@ -502,27 +490,45 @@ const module = defineNuxtModule({
|
|
|
502
490
|
setupNuxtConfigAppHeadWithMoreDefaults(nuxt);
|
|
503
491
|
if (config.extendNuxtConfigAppHeadTypes)
|
|
504
492
|
extendNuxtConfigAppHeadTypes();
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
493
|
+
addTypeTemplate({
|
|
494
|
+
filename: "module/nuxt-seo-utils.d.ts",
|
|
495
|
+
getContents: (data) => {
|
|
496
|
+
const typesPath = relative(resolve(data.nuxt.options.rootDir, data.nuxt.options.buildDir, "module"), resolve("runtime/types"));
|
|
497
|
+
const types = ` interface NitroRouteRules {
|
|
498
|
+
seoMeta?: import('${typesPath}').MetaFlatSerializable
|
|
499
|
+
head?: import('${typesPath}').Head
|
|
511
500
|
}
|
|
512
501
|
interface NitroRouteConfig {
|
|
513
|
-
seoMeta?: import('${
|
|
514
|
-
head?: import('${
|
|
515
|
-
}
|
|
502
|
+
seoMeta?: import('${typesPath}').MetaFlatSerializable
|
|
503
|
+
head?: import('${typesPath}').Head
|
|
504
|
+
}`;
|
|
505
|
+
return `// Generated by nuxt-seo-utils
|
|
506
|
+
|
|
507
|
+
import type { RobotsContext } from '#robots/types'
|
|
508
|
+
|
|
509
|
+
declare module 'nitropack/types' {
|
|
510
|
+
${types}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
declare module 'nitropack' {
|
|
514
|
+
${types}
|
|
516
515
|
}
|
|
517
516
|
|
|
517
|
+
|
|
518
518
|
declare module '@nuxt/schema' {
|
|
519
|
-
interface AppHeadMetaObject { seoMeta?: import('${
|
|
519
|
+
interface AppHeadMetaObject { seoMeta?: import('${typesPath}').MetaFlatSerializable }
|
|
520
520
|
}
|
|
521
521
|
|
|
522
522
|
declare module 'nuxt/schema' {
|
|
523
|
-
interface AppHeadMetaObject { seoMeta?: import('${
|
|
523
|
+
interface AppHeadMetaObject { seoMeta?: import('${typesPath}').MetaFlatSerializable }
|
|
524
524
|
}
|
|
525
|
+
|
|
526
|
+
export {}
|
|
525
527
|
`;
|
|
528
|
+
}
|
|
529
|
+
}, {
|
|
530
|
+
nitro: true,
|
|
531
|
+
nuxt: true
|
|
526
532
|
});
|
|
527
533
|
const appRuntimeDir = resolve(runtimeDir, "./app");
|
|
528
534
|
if (config.treeShakeUseSeoMeta)
|
|
@@ -122,7 +122,7 @@ export function useBreadcrumbItems(_options = {}) {
|
|
|
122
122
|
if (i18n.strategy === "prefix" || i18n.strategy !== "no_prefix" && toValue(i18n.defaultLocale) !== toValue(i18n.locale))
|
|
123
123
|
rootNode = `${rootNode}${toValue(i18n.locale)}`;
|
|
124
124
|
}
|
|
125
|
-
const current = withoutQuery(withoutTrailingSlash(flatOptions.path || toRaw(route)?.path || rootNode));
|
|
125
|
+
const current = withoutQuery(withoutTrailingSlash(flatOptions.path || toRaw(route)?.path || rootNode)) || "";
|
|
126
126
|
const segments = pathBreadcrumbSegments(current, rootNode).map((path, index) => {
|
|
127
127
|
let item = {
|
|
128
128
|
to: path
|
|
@@ -140,7 +140,7 @@ export function useBreadcrumbItems(_options = {}) {
|
|
|
140
140
|
return segments.filter(Boolean).map((item) => {
|
|
141
141
|
let fallbackLabel = titleCase(String((item.to || "").split("/").pop()));
|
|
142
142
|
let fallbackAriaLabel = "";
|
|
143
|
-
const route2 = item.to ? router.resolve(item.to)?.matched?.
|
|
143
|
+
const route2 = item.to ? router.resolve(item.to)?.matched?.at(-1) : null;
|
|
144
144
|
if (route2) {
|
|
145
145
|
const routeMeta = route2?.meta || {};
|
|
146
146
|
if (routeMeta.breadcrumb) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-seo-utils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.0.
|
|
4
|
+
"version": "7.0.13",
|
|
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,43 +32,43 @@
|
|
|
32
32
|
]
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@nuxt/kit": "^
|
|
36
|
-
"@unhead/addons": "^2.0.
|
|
35
|
+
"@nuxt/kit": "^4.0.0",
|
|
36
|
+
"@unhead/addons": "^2.0.12",
|
|
37
37
|
"defu": "^6.1.4",
|
|
38
38
|
"escape-string-regexp": "^5.0.0",
|
|
39
39
|
"fast-glob": "^3.3.3",
|
|
40
40
|
"image-size": "^2.0.2",
|
|
41
|
-
"nuxt-site-config": "^3.
|
|
41
|
+
"nuxt-site-config": "^3.2.2",
|
|
42
42
|
"pathe": "^2.0.3",
|
|
43
|
-
"pkg-types": "^2.
|
|
43
|
+
"pkg-types": "^2.2.0",
|
|
44
44
|
"scule": "^1.3.0",
|
|
45
45
|
"semver": "^7.7.2",
|
|
46
46
|
"ufo": "^1.6.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@antfu/eslint-config": "^4.
|
|
49
|
+
"@antfu/eslint-config": "^4.17.0",
|
|
50
50
|
"@nuxt/module-builder": "^1.0.1",
|
|
51
|
-
"@nuxt/schema": "^
|
|
52
|
-
"@nuxt/test-utils": "^3.19.
|
|
53
|
-
"@nuxt/ui": "^3.
|
|
51
|
+
"@nuxt/schema": "^4.0.0",
|
|
52
|
+
"@nuxt/test-utils": "^3.19.2",
|
|
53
|
+
"@nuxt/ui": "^3.2.0",
|
|
54
54
|
"@nuxtjs/eslint-config-typescript": "^12.1.0",
|
|
55
|
-
"@nuxtjs/i18n": "^
|
|
56
|
-
"@types/node": "^
|
|
57
|
-
"@unhead/vue": "^2.0.
|
|
55
|
+
"@nuxtjs/i18n": "^10.0.0",
|
|
56
|
+
"@types/node": "^24.0.15",
|
|
57
|
+
"@unhead/vue": "^2.0.12",
|
|
58
58
|
"@vue/test-utils": "^2.4.6",
|
|
59
|
-
"bumpp": "^10.
|
|
59
|
+
"bumpp": "^10.2.0",
|
|
60
60
|
"case-police": "^2.0.0",
|
|
61
|
-
"cheerio": "1.
|
|
62
|
-
"eslint": "^9.
|
|
63
|
-
"happy-dom": "^
|
|
61
|
+
"cheerio": "^1.1.0",
|
|
62
|
+
"eslint": "^9.31.0",
|
|
63
|
+
"happy-dom": "^18.0.1",
|
|
64
64
|
"markdownlint-cli": "^0.45.0",
|
|
65
|
-
"nuxt": "^
|
|
65
|
+
"nuxt": "^4.0.0",
|
|
66
66
|
"nuxt-content-twoslash": "^0.1.2",
|
|
67
|
-
"playwright-core": "^1.
|
|
68
|
-
"sass": "^1.89.
|
|
67
|
+
"playwright-core": "^1.54.1",
|
|
68
|
+
"sass": "^1.89.2",
|
|
69
69
|
"typescript": "^5.8.3",
|
|
70
|
-
"vitest": "^3.
|
|
71
|
-
"vue-tsc": "^
|
|
70
|
+
"vitest": "^3.2.4",
|
|
71
|
+
"vue-tsc": "^3.0.3"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
74
|
"lint": "eslint . --fix",
|