nuxt-seo-utils 7.0.0 → 7.0.2

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
@@ -1,5 +1,5 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
- import { UseSeoMetaInput } from '@unhead/schema';
2
+ import { UseSeoMetaInput } from '@unhead/vue/types';
3
3
 
4
4
  interface ModuleOptions {
5
5
  /**
package/dist/module.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
- import { UseSeoMetaInput } from '@unhead/schema';
2
+ import { UseSeoMetaInput } from '@unhead/vue/types';
3
3
 
4
4
  interface ModuleOptions {
5
5
  /**
package/dist/module.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "nuxt": ">=3.16.0",
6
6
  "bridge": false
7
7
  },
8
- "version": "6.0.12",
8
+ "version": "7.0.1",
9
9
  "builder": {
10
10
  "@nuxt/module-builder": "0.8.4",
11
11
  "unbuild": "2.0.0"
package/dist/module.mjs CHANGED
@@ -1,10 +1,9 @@
1
- import { useNuxt, createResolver, addTemplate, defineNuxtModule, useLogger, resolvePath, addServerHandler, hasNuxtModule, addPlugin, addImports, addVitePlugin } from '@nuxt/kit';
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, join } from 'pathe';
6
- import { readPackageJSON } from 'pkg-types';
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(unpackMeta, nuxt = useNuxt()) {
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(unpackMeta, nuxt = useNuxt()) {
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(unpackMeta);
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(unpackMeta);
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 = isUnheadV2 ? "@unhead/vue/types" : "@unhead/schema";
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, getCurrentInstance, provide, ref, toRaw, toValue } from "vue";
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,24 +20,23 @@ function titleCase(s) {
20
20
  const BreadcrumbCtx = Symbol("BreadcrumbCtx");
21
21
  export function useBreadcrumbItems(_options = {}) {
22
22
  const vm = getCurrentInstance();
23
- let isCreatingState = false;
23
+ const id = _options.id || "breadcrumb";
24
+ let stateRef = null;
24
25
  if (vm) {
25
- let stateRef2 = inject(BreadcrumbCtx, null);
26
- if (!stateRef2) {
27
- stateRef2 = ref({});
28
- provide(BreadcrumbCtx, stateRef2);
29
- isCreatingState = false;
26
+ stateRef = inject(BreadcrumbCtx, null);
27
+ if (!stateRef) {
28
+ stateRef = ref({});
29
+ provide(BreadcrumbCtx, stateRef);
30
30
  }
31
- const id2 = "breadcrumb";
32
- const state = stateRef2.value;
33
- if (!state[id2]) {
34
- state[id2] = [];
31
+ const state = stateRef.value;
32
+ if (!state[id]) {
33
+ state[id] = [];
35
34
  }
36
- const idx = state[id2].push(_options) - 1;
37
- stateRef2.value = state;
35
+ const idx = state[id].push(_options) - 1;
36
+ stateRef.value = state;
38
37
  onUnmounted(() => {
39
- stateRef2.value = Object.fromEntries(Object.entries(stateRef2.value).map(([k, v]) => {
40
- if (k === id2) {
38
+ stateRef.value = Object.fromEntries(Object.entries(stateRef.value).map(([k, v]) => {
39
+ if (k === id) {
41
40
  return v.filter((_, i) => i !== idx);
42
41
  }
43
42
  return v;
@@ -52,7 +51,7 @@ export function useBreadcrumbItems(_options = {}) {
52
51
  });
53
52
  const siteConfig = useSiteConfig();
54
53
  const items = computed(() => {
55
- const optionStack = stateRef.value?.[id];
54
+ const optionStack = stateRef?.value?.[id] || [_options];
56
55
  const flatOptions = toRaw([...optionStack]).reduce((acc, cur) => {
57
56
  acc.rootSegment = acc.rootSegment || cur.rootSegment;
58
57
  acc.path = acc.path || cur.path;
@@ -128,10 +127,10 @@ export function useBreadcrumbItems(_options = {}) {
128
127
  }).filter(Boolean);
129
128
  });
130
129
  const schemaOrgEnabled = typeof _options.schemaOrg === "undefined" ? true : _options.schemaOrg;
131
- if (isCreatingState && (import.meta.dev || import.meta.server || import.meta.env?.NODE_ENV === "test") && schemaOrgEnabled) {
130
+ if ((import.meta.dev || import.meta.server || import.meta.env?.NODE_ENV === "test") && schemaOrgEnabled) {
132
131
  useSchemaOrg([
133
132
  defineBreadcrumb({
134
- id: `#${_options.id || "breadcrumb"}`,
133
+ id: `#${id}`,
135
134
  itemListElement: computed(() => items.value.map((item) => ({
136
135
  name: item.label || item.ariaLabel,
137
136
  item: item.to ? siteResolver(item.to) : void 0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-seo-utils",
3
3
  "type": "module",
4
- "version": "7.0.0",
4
+ "version": "7.0.2",
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": "^1 || ^2"
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": "^1.2.0",
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,16 +56,14 @@
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.0",
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",
65
63
  "case-police": "^1.0.0",
66
64
  "cheerio": "1.0.0",
67
65
  "eslint": "^9.22.0",
68
- "happy-dom": "^17.4.2",
66
+ "happy-dom": "^17.4.3",
69
67
  "markdownlint-cli": "^0.44.0",
70
68
  "nuxt": "^3.16.0",
71
69
  "nuxt-content-twoslash": "^0.1.2",