nuxt-seo-utils 7.0.0 → 7.0.1
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.d.mts
CHANGED
package/dist/module.d.ts
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { useNuxt, createResolver, addTemplate, defineNuxtModule, useLogger,
|
|
1
|
+
import { useNuxt, createResolver, addTemplate, defineNuxtModule, useLogger, addServerHandler, hasNuxtModule, addPlugin, addImports, addVitePlugin, resolvePath } 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 { relative, resolve, extname, dirname, basename
|
|
6
|
-
import {
|
|
7
|
-
import { gte } from 'semver';
|
|
5
|
+
import { relative, resolve, extname, dirname, basename } from 'pathe';
|
|
6
|
+
import { unpackMeta } from '@unhead/vue/utils';
|
|
8
7
|
import fg from 'fast-glob';
|
|
9
8
|
import fs from 'node:fs';
|
|
10
9
|
import { encodePath, joinURL } from 'ufo';
|
|
@@ -12,7 +11,7 @@ import escapeRE from 'escape-string-regexp';
|
|
|
12
11
|
import { readFile } from 'node:fs/promises';
|
|
13
12
|
import imageSize from 'image-size';
|
|
14
13
|
|
|
15
|
-
function extendNuxtConfigAppHeadSeoMeta(
|
|
14
|
+
function extendNuxtConfigAppHeadSeoMeta(nuxt = useNuxt()) {
|
|
16
15
|
const seoMeta = nuxt.options.app?.seoMeta || nuxt.options.app?.head?.seoMeta || false;
|
|
17
16
|
const configSeoMeta = nuxt.options.seo?.meta || nuxt.options.seo?.seoMeta || false;
|
|
18
17
|
if (!seoMeta && !configSeoMeta)
|
|
@@ -188,15 +187,6 @@ function parseSegment(segment) {
|
|
|
188
187
|
return tokens;
|
|
189
188
|
}
|
|
190
189
|
|
|
191
|
-
async function resolveUnpackMeta(unheadV2) {
|
|
192
|
-
try {
|
|
193
|
-
const unhead = await import(String(unheadV2 ? "@unhead/vue/util" : "@unhead/shared"));
|
|
194
|
-
return unhead.unpackMeta;
|
|
195
|
-
} catch {
|
|
196
|
-
const unhead = await import(String(!unheadV2 ? "@unhead/vue/util" : "@unhead/shared"));
|
|
197
|
-
return unhead.unpackMeta;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
190
|
function hasLinkRel(input, rel) {
|
|
201
191
|
return input.link?.some((link) => link.rel === rel);
|
|
202
192
|
}
|
|
@@ -296,7 +286,7 @@ async function generateTagsFromPageDirImages(nuxt = useNuxt()) {
|
|
|
296
286
|
});
|
|
297
287
|
}
|
|
298
288
|
|
|
299
|
-
async function generateTagsFromPublicFiles(
|
|
289
|
+
async function generateTagsFromPublicFiles(nuxt = useNuxt()) {
|
|
300
290
|
const publicDirPath = resolve(nuxt.options.rootDir, nuxt.options.dir.public);
|
|
301
291
|
const rootPublicFiles = (await fg(MetaTagFileGlobs, { cwd: publicDirPath, onlyFiles: true, deep: 1 })).map((file) => basename(file));
|
|
302
292
|
const headConfig = defu(nuxt.options.app.head, {
|
|
@@ -430,18 +420,9 @@ const module = defineNuxtModule({
|
|
|
430
420
|
}
|
|
431
421
|
const { resolve } = createResolver(import.meta.url);
|
|
432
422
|
await installNuxtSiteConfig();
|
|
433
|
-
let isUnheadV2 = false;
|
|
434
|
-
const unheadPath = await resolvePath("@unhead/vue").catch(() => void 0).then((p) => p?.endsWith("index.mjs") ? dirname(p) : p);
|
|
435
|
-
if (unheadPath) {
|
|
436
|
-
const { version: unheadVersion } = await readPackageJSON(join(unheadPath, "package.json"));
|
|
437
|
-
if (gte(unheadVersion, "2.0.0-rc.1")) {
|
|
438
|
-
isUnheadV2 = true;
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
423
|
const runtimeDir = resolve("./runtime");
|
|
442
|
-
const unpackMeta = await resolveUnpackMeta(isUnheadV2);
|
|
443
424
|
if (config.metaDataFiles) {
|
|
444
|
-
await generateTagsFromPublicFiles(
|
|
425
|
+
await generateTagsFromPublicFiles();
|
|
445
426
|
await generateTagsFromPageDirImages();
|
|
446
427
|
if (nuxt.options.dev) {
|
|
447
428
|
addServerHandler({
|
|
@@ -513,13 +494,13 @@ const module = defineNuxtModule({
|
|
|
513
494
|
canonicalLowercase: config.canonicalLowercase
|
|
514
495
|
});
|
|
515
496
|
if (config.extendNuxtConfigAppHeadSeoMeta)
|
|
516
|
-
extendNuxtConfigAppHeadSeoMeta(
|
|
497
|
+
extendNuxtConfigAppHeadSeoMeta();
|
|
517
498
|
if (config.setupNuxtConfigAppHeadWithMoreDefaults)
|
|
518
499
|
setupNuxtConfigAppHeadWithMoreDefaults(nuxt);
|
|
519
500
|
if (config.extendNuxtConfigAppHeadTypes)
|
|
520
501
|
extendNuxtConfigAppHeadTypes();
|
|
521
502
|
extendTypes("nuxt-seo-utils", async () => {
|
|
522
|
-
const pkg =
|
|
503
|
+
const pkg = "@unhead/vue/types";
|
|
523
504
|
let unheadSchemaPath;
|
|
524
505
|
try {
|
|
525
506
|
unheadSchemaPath = relative(resolve(nuxt.options.rootDir, nuxt.options.buildDir, "module"), await resolvePath(pkg));
|
|
@@ -9,7 +9,7 @@ import { defu } from "defu";
|
|
|
9
9
|
import { fixSlashes } from "nuxt-site-config/urls";
|
|
10
10
|
import { useRouter } from "nuxt/app";
|
|
11
11
|
import { withoutTrailingSlash } from "ufo";
|
|
12
|
-
import { computed, inject, onUnmounted,
|
|
12
|
+
import { computed, getCurrentInstance, inject, onUnmounted, provide, ref, toRaw, toValue } from "vue";
|
|
13
13
|
import { pathBreadcrumbSegments } from "../../shared/breadcrumbs.js";
|
|
14
14
|
function withoutQuery(path) {
|
|
15
15
|
return path.split("?")[0];
|
|
@@ -20,23 +20,24 @@ function titleCase(s) {
|
|
|
20
20
|
const BreadcrumbCtx = Symbol("BreadcrumbCtx");
|
|
21
21
|
export function useBreadcrumbItems(_options = {}) {
|
|
22
22
|
const vm = getCurrentInstance();
|
|
23
|
+
let stateRef = null;
|
|
23
24
|
let isCreatingState = false;
|
|
24
25
|
if (vm) {
|
|
25
|
-
|
|
26
|
-
if (!
|
|
27
|
-
|
|
28
|
-
provide(BreadcrumbCtx,
|
|
26
|
+
stateRef = inject(BreadcrumbCtx, null);
|
|
27
|
+
if (!stateRef) {
|
|
28
|
+
stateRef = ref({});
|
|
29
|
+
provide(BreadcrumbCtx, stateRef);
|
|
29
30
|
isCreatingState = false;
|
|
30
31
|
}
|
|
31
32
|
const id2 = "breadcrumb";
|
|
32
|
-
const state =
|
|
33
|
+
const state = stateRef.value;
|
|
33
34
|
if (!state[id2]) {
|
|
34
35
|
state[id2] = [];
|
|
35
36
|
}
|
|
36
37
|
const idx = state[id2].push(_options) - 1;
|
|
37
|
-
|
|
38
|
+
stateRef.value = state;
|
|
38
39
|
onUnmounted(() => {
|
|
39
|
-
|
|
40
|
+
stateRef.value = Object.fromEntries(Object.entries(stateRef.value).map(([k, v]) => {
|
|
40
41
|
if (k === id2) {
|
|
41
42
|
return v.filter((_, i) => i !== idx);
|
|
42
43
|
}
|
|
@@ -52,7 +53,7 @@ export function useBreadcrumbItems(_options = {}) {
|
|
|
52
53
|
});
|
|
53
54
|
const siteConfig = useSiteConfig();
|
|
54
55
|
const items = computed(() => {
|
|
55
|
-
const optionStack = stateRef
|
|
56
|
+
const optionStack = stateRef?.value?.[id] || [_options];
|
|
56
57
|
const flatOptions = toRaw([...optionStack]).reduce((acc, cur) => {
|
|
57
58
|
acc.rootSegment = acc.rootSegment || cur.rootSegment;
|
|
58
59
|
acc.path = acc.path || cur.path;
|
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.1",
|
|
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",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
]
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@unhead/vue": "^
|
|
37
|
+
"@unhead/vue": "^2.0.0-rc.9"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@nuxt/kit": "^3.16.0",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"defu": "^6.1.4",
|
|
43
43
|
"escape-string-regexp": "^5.0.0",
|
|
44
44
|
"fast-glob": "^3.3.3",
|
|
45
|
-
"image-size": "^
|
|
45
|
+
"image-size": "^2.0.0",
|
|
46
46
|
"nuxt-site-config": "^3.1.4",
|
|
47
47
|
"pathe": "^2.0.3",
|
|
48
48
|
"pkg-types": "^2.1.0",
|
|
@@ -56,9 +56,7 @@
|
|
|
56
56
|
"@nuxt/test-utils": "^3.17.2",
|
|
57
57
|
"@nuxt/ui": "^2.21.1",
|
|
58
58
|
"@nuxtjs/eslint-config-typescript": "^12.1.0",
|
|
59
|
-
"@nuxtjs/i18n": "^9.3.
|
|
60
|
-
"@unhead/schema": "^1.11.20",
|
|
61
|
-
"@unhead/shared": "^1.11.20",
|
|
59
|
+
"@nuxtjs/i18n": "^9.3.1",
|
|
62
60
|
"@unhead/vue": "2.0.0-rc.9",
|
|
63
61
|
"@vue/test-utils": "^2.4.6",
|
|
64
62
|
"bumpp": "^10.0.3",
|