@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 +1 -1
- package/dist/module.mjs +20 -9
- package/dist/runtime/nuxt/composables/useBreadcrumbItems.d.ts +1 -1
- package/dist/runtime/nuxt/composables/useBreadcrumbItems.mjs +7 -2
- package/dist/runtime/nuxt/logic/applyDefaults.d.ts +1 -0
- package/dist/runtime/nuxt/logic/applyDefaults.mjs +46 -0
- package/dist/runtime/nuxt/plugin/defaults.mjs +6 -45
- package/dist/runtime/nuxt/plugin/defaultsWaitI18n.server.d.ts +2 -0
- package/dist/runtime/nuxt/plugin/defaultsWaitI18n.server.mjs +14 -0
- package/dist/runtime/nuxt/plugin/titles.mjs +3 -0
- package/dist/runtime/nuxt/tsconfig.json +3 -0
- package/package.json +26 -25
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, useLogger, installModule,
|
|
2
|
-
import
|
|
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
|
-
|
|
48
|
-
|
|
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(`${
|
|
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(`${
|
|
98
|
-
logger.log(
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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,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
|
+
});
|
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.
|
|
5
|
-
"packageManager": "pnpm@8.15.
|
|
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.
|
|
36
|
-
"@nuxtjs/sitemap": "^5.1.
|
|
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.
|
|
40
|
-
"nuxt-og-image": "^3.0.0-rc.
|
|
41
|
-
"nuxt-schema-org": "^3.3.
|
|
42
|
-
"nuxt-seo-experiments": "
|
|
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.
|
|
45
|
-
"nuxt-site-config-kit": "^2.2.
|
|
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.
|
|
46
|
+
"ufo": "^1.4.0"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|
|
50
|
-
"@antfu/eslint-config": "^2.
|
|
49
|
+
"@antfu/eslint-config": "^2.8.0",
|
|
51
50
|
"@nuxt/module-builder": "^0.5.5",
|
|
52
|
-
"@nuxt/schema": "^3.10.
|
|
51
|
+
"@nuxt/schema": "^3.10.3",
|
|
53
52
|
"@nuxt/test-utils": "3.11.0",
|
|
54
|
-
"@nuxt/ui": "^2.
|
|
55
|
-
"@nuxtjs/i18n": "8.
|
|
56
|
-
"bumpp": "^9.
|
|
57
|
-
"eslint": "^8.
|
|
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.
|
|
60
|
-
"nuxt": "^3.10.
|
|
61
|
-
"nuxt-icon": "^0.6.
|
|
62
|
-
"typescript": "^5.
|
|
63
|
-
"vitest": "^1.
|
|
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
|
}
|