@nuxtjs/seo 2.0.0-rc.7 → 2.0.0-rc.9

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
@@ -5,5 +5,5 @@
5
5
  "bridge": false
6
6
  },
7
7
  "configKey": "seo",
8
- "version": "2.0.0-rc.6"
8
+ "version": "2.0.0-rc.8"
9
9
  }
package/dist/module.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { defineNuxtModule, createResolver, useLogger, installModule, addPlugin, hasNuxtModule, addImports, addServerHandler } from '@nuxt/kit';
2
- import chalk from 'chalk';
1
+ import { defineNuxtModule, createResolver, useLogger, installModule, hasNuxtModule, addPlugin, addImports, addServerHandler } from '@nuxt/kit';
2
+ import { colors } from 'consola/utils';
3
3
  import { installNuxtSiteConfig } from 'nuxt-site-config-kit';
4
4
  import { readPackageJSON } from 'pkg-types';
5
5
  import { $fetch } from 'ofetch';
@@ -44,9 +44,20 @@ const module = defineNuxtModule({
44
44
  for (const module of Modules)
45
45
  await installModule(await resolvePath(module));
46
46
  if (config.automaticDefaults) {
47
- addPlugin({
48
- src: resolve("./runtime/nuxt/plugin/defaults")
49
- });
47
+ if (hasNuxtModule("@nuxtjs/i18n")) {
48
+ addPlugin({
49
+ src: resolve(`./runtime/nuxt/plugin/defaultsWaitI18n.server`),
50
+ mode: "server"
51
+ });
52
+ addPlugin({
53
+ src: resolve(`./runtime/nuxt/plugin/defaults`),
54
+ mode: "client"
55
+ });
56
+ } else {
57
+ addPlugin({
58
+ src: resolve(`./runtime/nuxt/plugin/defaults`)
59
+ });
60
+ }
50
61
  }
51
62
  if (config.fallbackTitle) {
52
63
  addPlugin({
@@ -83,7 +94,7 @@ const module = defineNuxtModule({
83
94
  middleware: true
84
95
  });
85
96
  }
86
- if (config.splash) {
97
+ if (config.splash && !version.includes("rc") && nuxt.options.dev) {
87
98
  logger.log("");
88
99
  let latestTag = `v${version}`;
89
100
  latestTag = (await $fetch("https://ungh.unjs.io/repos/harlan-zw/nuxt-seo/releases/latest", {
@@ -92,10 +103,10 @@ const module = defineNuxtModule({
92
103
  return { release: { tag: `v${version}` } };
93
104
  })).release.tag;
94
105
  const upToDate = latestTag === `v${version}`;
95
- logger.log(`${chalk.green("Nuxt SEO")} ${chalk.yellow(`v${version}`)} ${chalk.gray(`by ${chalk.underline("@harlan_zw")}`)}`);
106
+ logger.log(`${colors.green("Nuxt SEO")} ${colors.yellow(`v${version}`)} ${colors.gray(`by ${colors.underline("@harlan_zw")}`)}`);
96
107
  if (!upToDate)
97
- logger.log(`${chalk.gray(" \u251C\u2500 ")}\u{1F389} New version available!${chalk.gray(` Run ${chalk.underline(`npm i @nuxtjs/seo@${latestTag}`)} to update.`)}`);
98
- logger.log(chalk.dim(" \u2514\u2500 \u{1F9EA} Help get Nuxt SEO stable by providing feedback https://github.com/harlan-zw/nuxt-seo/discussions/108"));
108
+ logger.log(`${colors.gray(" \u251C\u2500 ")}\u{1F389} New version available!${colors.gray(` Run ${colors.underline(`npm i @nuxtjs/seo@${latestTag}`)} to update.`)}`);
109
+ logger.log(colors.dim(" \u2514\u2500 \u{1F9EA} Help get Nuxt SEO stable by providing feedback https://github.com/harlan-zw/nuxt-seo/discussions/108"));
99
110
  logger.log("");
100
111
  }
101
112
  }
@@ -70,7 +70,7 @@ export interface BreadcrumbItemProps extends NuxtUIBreadcrumbItem {
70
70
  * @default 'page'
71
71
  */
72
72
  ariaCurrent?: 'page' | 'step' | 'location' | 'date' | 'time' | boolean | 'true' | 'false';
73
- to: string;
73
+ to?: string;
74
74
  ariaLabel?: string;
75
75
  separator?: boolean | string;
76
76
  class?: (string | string[] | undefined)[] | string;
@@ -3,6 +3,7 @@ import { defu } from "defu";
3
3
  import { pathBreadcrumbSegments } from "../../pure/breadcrumbs.mjs";
4
4
  import {
5
5
  computed,
6
+ createSitePathResolver,
6
7
  defineBreadcrumb,
7
8
  toValue,
8
9
  useI18n,
@@ -21,6 +22,10 @@ export function useBreadcrumbItems(options = {}) {
21
22
  const router = useRouter();
22
23
  const routes = router.getRoutes();
23
24
  const i18n = useI18n();
25
+ const siteResolver = createSitePathResolver({
26
+ canonical: true,
27
+ absolute: true
28
+ });
24
29
  const items = computed(() => {
25
30
  let rootNode = "/";
26
31
  if (i18n) {
@@ -50,7 +55,7 @@ export function useBreadcrumbItems(options = {}) {
50
55
  const routeName = route ? String(route.name || route.path) : item.to === "/" ? "index" : "unknown";
51
56
  let [name] = routeName.split("___");
52
57
  if (name === "unknown")
53
- name = item.to.split("/").pop() || "";
58
+ name = (item.to || "").split("/").pop() || "";
54
59
  if (routeMeta.breadcrumb) {
55
60
  item = {
56
61
  ...item,
@@ -84,7 +89,7 @@ export function useBreadcrumbItems(options = {}) {
84
89
  id: `#${options.id || "breadcrumb"}`,
85
90
  itemListElement: items.value.map((item) => ({
86
91
  name: item.label || item.ariaLabel,
87
- item: item.to
92
+ item: item.to ? siteResolver(item.to) : void 0
88
93
  }))
89
94
  };
90
95
  }))
@@ -0,0 +1 @@
1
+ export declare function applyDefaults(): void;
@@ -0,0 +1,46 @@
1
+ import {
2
+ computed,
3
+ createSitePathResolver,
4
+ useHead,
5
+ useRoute,
6
+ useSeoMeta,
7
+ useServerHead,
8
+ useSiteConfig
9
+ } from "#imports";
10
+ export function applyDefaults() {
11
+ const siteConfig = useSiteConfig();
12
+ const route = useRoute();
13
+ const resolveUrl = createSitePathResolver({ withBase: true, absolute: true });
14
+ const canonicalUrl = computed(() => resolveUrl(route.path || "/").value || route.path);
15
+ const minimalPriority = {
16
+ // give nuxt.config values higher priority
17
+ tagPriority: 101
18
+ };
19
+ useHead({
20
+ link: [{ rel: "canonical", href: () => canonicalUrl.value }]
21
+ });
22
+ const locale = siteConfig.currentLocale || siteConfig.defaultLocale;
23
+ if (locale) {
24
+ useServerHead({
25
+ htmlAttrs: { lang: locale }
26
+ });
27
+ }
28
+ useHead({
29
+ templateParams: { site: siteConfig, siteName: siteConfig.name || "" },
30
+ titleTemplate: "%s %separator %siteName"
31
+ }, minimalPriority);
32
+ const seoMeta = {
33
+ ogType: "website",
34
+ ogUrl: () => canonicalUrl.value,
35
+ ogLocale: locale,
36
+ ogSiteName: siteConfig.name
37
+ };
38
+ if (siteConfig.description)
39
+ seoMeta.description = siteConfig.description;
40
+ if (siteConfig.twitter) {
41
+ const id = siteConfig.twitter.startsWith("@") ? siteConfig.twitter : `@${siteConfig.twitter}`;
42
+ seoMeta.twitterCreator = id;
43
+ seoMeta.twitterSite = id;
44
+ }
45
+ useSeoMeta(seoMeta, minimalPriority);
46
+ }
@@ -1,50 +1,11 @@
1
+ import { applyDefaults as setup } from "../logic/applyDefaults.mjs";
1
2
  import {
2
- computed,
3
- createSitePathResolver,
4
- defineNuxtPlugin,
5
- useHead,
6
- useRoute,
7
- useSeoMeta,
8
- useServerHead,
9
- useSiteConfig
3
+ defineNuxtPlugin
10
4
  } from "#imports";
11
5
  export default defineNuxtPlugin({
12
6
  name: "nuxt-seo:defaults",
13
- setup() {
14
- const siteConfig = useSiteConfig();
15
- const route = useRoute();
16
- const resolveUrl = createSitePathResolver({ withBase: true, absolute: true });
17
- const canonicalUrl = computed(() => resolveUrl(route.path || "/").value || route.path);
18
- const minimalPriority = {
19
- // give nuxt.config values higher priority
20
- tagPriority: 101
21
- };
22
- useHead({
23
- link: [{ rel: "canonical", href: () => canonicalUrl.value }]
24
- });
25
- const locale = siteConfig.currentLocale || siteConfig.defaultLocale;
26
- if (locale) {
27
- useServerHead({
28
- htmlAttrs: { lang: locale }
29
- });
30
- }
31
- useHead({
32
- templateParams: { site: siteConfig, siteName: siteConfig.name || "" },
33
- titleTemplate: "%s %separator %siteName"
34
- }, minimalPriority);
35
- const seoMeta = {
36
- ogType: "website",
37
- ogUrl: () => canonicalUrl.value,
38
- ogLocale: locale,
39
- ogSiteName: siteConfig.name
40
- };
41
- if (siteConfig.description)
42
- seoMeta.description = siteConfig.description;
43
- if (siteConfig.twitter) {
44
- const id = siteConfig.twitter.startsWith("@") ? siteConfig.twitter : `@${siteConfig.twitter}`;
45
- seoMeta.twitterCreator = id;
46
- seoMeta.twitterSite = id;
47
- }
48
- useSeoMeta(seoMeta, minimalPriority);
49
- }
7
+ env: {
8
+ islands: false
9
+ },
10
+ setup
50
11
  });
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,14 @@
1
+ import { applyDefaults as setup } from "../logic/applyDefaults.mjs";
2
+ import { defineNuxtPlugin } from "#imports";
3
+ export default defineNuxtPlugin({
4
+ name: "nuxt-seo:defaults",
5
+ env: {
6
+ islands: false
7
+ },
8
+ // we need to wait for the i18n plugin to run first
9
+ dependsOn: [
10
+ // @ts-expect-error dynamic
11
+ "nuxt-site-config:i18n"
12
+ ],
13
+ setup
14
+ });
@@ -10,6 +10,9 @@ function titleCase(s) {
10
10
  }
11
11
  export default defineNuxtPlugin({
12
12
  name: "nuxt-seo:fallback-titles",
13
+ env: {
14
+ islands: false
15
+ },
13
16
  setup() {
14
17
  const route = useRoute();
15
18
  const title = computed(() => {
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "../../../.nuxt/tsconfig.json"
3
+ }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@nuxtjs/seo",
3
3
  "type": "module",
4
- "version": "2.0.0-rc.7",
5
- "packageManager": "pnpm@8.15.1",
4
+ "version": "2.0.0-rc.9",
5
+ "packageManager": "pnpm@8.15.4",
6
6
  "description": "The all-in-one SEO layer for Nuxt 3.",
7
7
  "author": {
8
8
  "name": "Harlan Wilton",
@@ -32,47 +32,48 @@
32
32
  "dist"
33
33
  ],
34
34
  "dependencies": {
35
- "@nuxt/kit": "^3.10.0",
36
- "@nuxtjs/sitemap": "^5.1.0",
37
- "chalk": "^5.3.0",
35
+ "@nuxt/kit": "^3.10.3",
36
+ "@nuxtjs/sitemap": "^5.1.2",
38
37
  "defu": "^6.1.4",
39
- "nuxt-link-checker": "^3.0.0-rc.6",
40
- "nuxt-og-image": "^3.0.0-rc.37",
41
- "nuxt-schema-org": "^3.3.4",
42
- "nuxt-seo-experiments": "^4.0.0-rc.2",
38
+ "nuxt-link-checker": "^3.0.0-rc.7",
39
+ "nuxt-og-image": "^3.0.0-rc.42",
40
+ "nuxt-schema-org": "^3.3.6",
41
+ "nuxt-seo-experiments": "4.0.0-rc.5",
43
42
  "nuxt-simple-robots": "^4.0.0-rc.14",
44
- "nuxt-site-config": "^2.2.9",
45
- "nuxt-site-config-kit": "^2.2.9",
43
+ "nuxt-site-config": "^2.2.11",
44
+ "nuxt-site-config-kit": "^2.2.11",
46
45
  "pkg-types": "^1.0.3",
47
- "ufo": "^1.3.2"
46
+ "ufo": "^1.4.0"
48
47
  },
49
48
  "devDependencies": {
50
- "@antfu/eslint-config": "^2.6.3",
49
+ "@antfu/eslint-config": "^2.8.0",
51
50
  "@nuxt/module-builder": "^0.5.5",
52
- "@nuxt/schema": "^3.10.0",
51
+ "@nuxt/schema": "^3.10.3",
53
52
  "@nuxt/test-utils": "3.11.0",
54
- "@nuxt/ui": "^2.13.0",
55
- "@nuxtjs/i18n": "8.0.1",
56
- "bumpp": "^9.3.0",
57
- "eslint": "^8.56.0",
53
+ "@nuxt/ui": "^2.14.2",
54
+ "@nuxtjs/i18n": "8.1.1",
55
+ "bumpp": "^9.4.0",
56
+ "eslint": "^8.57.0",
58
57
  "execa": "^8.0.1",
59
- "nitropack": "^2.8.1",
60
- "nuxt": "^3.10.0",
61
- "nuxt-icon": "^0.6.8",
62
- "typescript": "^5.3.3",
63
- "vitest": "^1.2.2"
58
+ "nitropack": "^2.9.3",
59
+ "nuxt": "^3.10.3",
60
+ "nuxt-icon": "^0.6.9",
61
+ "typescript": "^5.4.2",
62
+ "vitest": "^1.3.1"
64
63
  },
65
64
  "build": {
66
65
  "externals": [
67
- "ofetch"
66
+ "ofetch",
67
+ "consola/utils"
68
68
  ]
69
69
  },
70
70
  "scripts": {
71
71
  "build": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt-module-build build",
72
72
  "dev": "nuxi dev .playground",
73
+ "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare .playground",
73
74
  "lint": "eslint . --fix",
74
75
  "release": "pnpm build && bumpp && pnpm -r publish --access public",
75
76
  "test": "nuxi prepare .playground && vitest",
76
- "typecheck": "tsc --noEmit --strict"
77
+ "typecheck": "npx vue-tsc --noEmit --strict"
77
78
  }
78
79
  }