@nuxtjs/seo 2.0.0-rc.13 → 2.0.0-rc.15

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.
@@ -0,0 +1,46 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+
3
+ interface ModuleOptions {
4
+ /**
5
+ * Will ensure a title is always set by providing a fallback title based on the casing the last slug segment.
6
+ *
7
+ * @default true
8
+ */
9
+ fallbackTitle?: boolean;
10
+ /**
11
+ * Will set up a number of defaults for meta tags and Schema.org, if the modules and config are available.
12
+ *
13
+ * @default true
14
+ */
15
+ automaticDefaults?: boolean;
16
+ /**
17
+ * When enabled, it will redirect any request to the canonical domain (site url) using a 301 redirect on non-dev environments.
18
+ *
19
+ * E.g if the site url is 'www.example.com' and the user visits 'example.com',
20
+ * they will be redirected to 'www.example.com'.
21
+ *
22
+ * This is useful for SEO as it prevents duplicate content and consolidates page rank.
23
+ *
24
+ * @default false
25
+ */
26
+ redirectToCanonicalSiteUrl?: boolean;
27
+ /**
28
+ * Whether the module should be loaded.
29
+ */
30
+ enabled: boolean;
31
+ /**
32
+ * Whether the debugging mode should be enabled.
33
+ *
34
+ * @default `nuxt.options.debug`
35
+ */
36
+ debug: boolean;
37
+ /**
38
+ * Whether the Nuxt SEO splash should be shown when Nuxt is started.
39
+ *
40
+ * @default `nuxt.options.dev`
41
+ */
42
+ splash: boolean;
43
+ }
44
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
45
+
46
+ export { type ModuleOptions, _default as default };
package/dist/module.d.ts CHANGED
@@ -1,2 +1,46 @@
1
- export * from "/home/harlan/packages/nuxt-seo/src/module";
2
- export { default } from "/home/harlan/packages/nuxt-seo/src/module";
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+
3
+ interface ModuleOptions {
4
+ /**
5
+ * Will ensure a title is always set by providing a fallback title based on the casing the last slug segment.
6
+ *
7
+ * @default true
8
+ */
9
+ fallbackTitle?: boolean;
10
+ /**
11
+ * Will set up a number of defaults for meta tags and Schema.org, if the modules and config are available.
12
+ *
13
+ * @default true
14
+ */
15
+ automaticDefaults?: boolean;
16
+ /**
17
+ * When enabled, it will redirect any request to the canonical domain (site url) using a 301 redirect on non-dev environments.
18
+ *
19
+ * E.g if the site url is 'www.example.com' and the user visits 'example.com',
20
+ * they will be redirected to 'www.example.com'.
21
+ *
22
+ * This is useful for SEO as it prevents duplicate content and consolidates page rank.
23
+ *
24
+ * @default false
25
+ */
26
+ redirectToCanonicalSiteUrl?: boolean;
27
+ /**
28
+ * Whether the module should be loaded.
29
+ */
30
+ enabled: boolean;
31
+ /**
32
+ * Whether the debugging mode should be enabled.
33
+ *
34
+ * @default `nuxt.options.debug`
35
+ */
36
+ debug: boolean;
37
+ /**
38
+ * Whether the Nuxt SEO splash should be shown when Nuxt is started.
39
+ *
40
+ * @default `nuxt.options.dev`
41
+ */
42
+ splash: boolean;
43
+ }
44
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
45
+
46
+ export { type ModuleOptions, _default as default };
package/dist/module.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "bridge": false
6
6
  },
7
7
  "configKey": "seo",
8
- "version": "2.0.0-rc.13",
8
+ "version": "2.0.0-rc.14",
9
9
  "builder": {
10
10
  "@nuxt/module-builder": "0.8.1",
11
11
  "unbuild": "2.0.0"
package/dist/module.mjs CHANGED
@@ -1,12 +1,116 @@
1
- import jiti from "file:///home/harlan/packages/nuxt-seo/node_modules/.pnpm/jiti@1.21.6/node_modules/jiti/lib/index.js";
1
+ import { defineNuxtModule, createResolver, useLogger, installModule, hasNuxtModule, addPlugin, addImports, addServerHandler } from '@nuxt/kit';
2
+ import { colors } from 'consola/utils';
3
+ import { installNuxtSiteConfig } from 'nuxt-site-config-kit';
4
+ import { readPackageJSON } from 'pkg-types';
5
+ import { $fetch } from 'ofetch';
2
6
 
3
- /** @type {import("/home/harlan/packages/nuxt-seo/src/module")} */
4
- const _module = jiti(null, {
5
- "esmResolve": true,
6
- "interopDefault": true,
7
- "alias": {
8
- "@nuxtjs/seo": "/home/harlan/packages/nuxt-seo"
7
+ const Modules = [
8
+ "@nuxtjs/robots",
9
+ "@nuxtjs/sitemap",
10
+ "nuxt-og-image",
11
+ "nuxt-schema-org",
12
+ "nuxt-seo-experiments",
13
+ "nuxt-link-checker"
14
+ ];
15
+ const module = defineNuxtModule({
16
+ meta: {
17
+ name: "nuxtseo",
18
+ compatibility: {
19
+ nuxt: ">=3.7.0",
20
+ bridge: false
21
+ },
22
+ configKey: "seo"
23
+ },
24
+ defaults(nuxt) {
25
+ return {
26
+ enabled: true,
27
+ debug: nuxt.options.debug,
28
+ redirectToCanonicalSiteUrl: false,
29
+ splash: false,
30
+ // nuxt.options.dev, - figure out a solution for this in the future
31
+ automaticDefaults: true,
32
+ fallbackTitle: true
33
+ };
34
+ },
35
+ async setup(config, nuxt) {
36
+ const { resolve, resolvePath } = createResolver(import.meta.url);
37
+ const { name, version } = await readPackageJSON(resolve("../package.json"));
38
+ const logger = useLogger(name);
39
+ logger.level = config.debug ? 4 : 3;
40
+ if (config.enabled === false) {
41
+ logger.debug("The module is disabled, skipping setup.");
42
+ return;
43
+ }
44
+ await installNuxtSiteConfig();
45
+ for (const module of Modules)
46
+ await installModule(await resolvePath(module));
47
+ if (config.automaticDefaults) {
48
+ if (hasNuxtModule("@nuxtjs/i18n")) {
49
+ addPlugin({
50
+ src: resolve(`./runtime/nuxt/plugin/defaultsWaitI18n.server`),
51
+ mode: "server"
52
+ });
53
+ addPlugin({
54
+ src: resolve(`./runtime/nuxt/plugin/defaults`),
55
+ mode: "client"
56
+ });
57
+ } else {
58
+ addPlugin({
59
+ src: resolve(`./runtime/nuxt/plugin/defaults`)
60
+ });
61
+ }
62
+ }
63
+ if (config.fallbackTitle) {
64
+ addPlugin({
65
+ src: resolve("./runtime/nuxt/plugin/titles")
66
+ });
67
+ }
68
+ if (!hasNuxtModule("@nuxtjs/i18n")) {
69
+ addImports({
70
+ from: resolve(`./runtime/nuxt/composables/polyfills`),
71
+ name: "useI18n"
72
+ });
73
+ }
74
+ addImports({
75
+ from: resolve(`./runtime/nuxt/composables/useBreadcrumbItems`),
76
+ name: "useBreadcrumbItems"
77
+ });
78
+ const polyfills = {
79
+ schemaOrg: ["useSchemaOrg", "defineWebSite", "defineWebPage"]
80
+ };
81
+ for (const [module, composables] of Object.entries(polyfills)) {
82
+ if (nuxt.options[module]?.enable === false) {
83
+ composables.forEach((name2) => {
84
+ addImports({
85
+ from: resolve("./runtime/nuxt/composables/polyfills"),
86
+ name: name2
87
+ });
88
+ });
89
+ }
90
+ }
91
+ nuxt.options.experimental.headNext = true;
92
+ if (!nuxt.options.dev && config.redirectToCanonicalSiteUrl) {
93
+ addServerHandler({
94
+ handler: resolve("./runtime/nitro/middleware/redirect"),
95
+ middleware: true
96
+ });
97
+ }
98
+ if (config.splash && !version.includes("rc") && nuxt.options.dev) {
99
+ logger.log("");
100
+ let latestTag = `v${version}`;
101
+ latestTag = (await $fetch("https://ungh.unjs.io/repos/harlan-zw/nuxt-seo/releases/latest", {
102
+ timeout: 2e3
103
+ }).catch(() => {
104
+ return { release: { tag: `v${version}` } };
105
+ })).release.tag;
106
+ const upToDate = latestTag === `v${version}`;
107
+ logger.log(`${colors.green("Nuxt SEO")} ${colors.yellow(`v${version}`)} ${colors.gray(`by ${colors.underline("@harlan_zw")}`)}`);
108
+ if (!upToDate)
109
+ logger.log(`${colors.gray(" \u251C\u2500 ")}\u{1F389} New version available!${colors.gray(` Run ${colors.underline(`npm i @nuxtjs/seo@${latestTag}`)} to update.`)}`);
110
+ 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"));
111
+ logger.log("");
112
+ }
9
113
  }
10
- })("/home/harlan/packages/nuxt-seo/src/module.ts");
114
+ });
11
115
 
12
- export default _module;
116
+ export { module as default };
@@ -0,0 +1,2 @@
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void> | undefined>;
2
+ export default _default;
@@ -0,0 +1,18 @@
1
+ import { defineEventHandler, sendRedirect, setHeader } from "h3";
2
+ import { joinURL } from "ufo";
3
+ import { useNitroOrigin, useSiteConfig } from "#imports";
4
+ export default defineEventHandler((e) => {
5
+ const siteConfig = useSiteConfig(e);
6
+ if (siteConfig.url) {
7
+ const siteConfigHostName = new URL(e.path, siteConfig.url).hostname;
8
+ const origin = useNitroOrigin(e);
9
+ const originHostname = new URL(e.path, origin).hostname;
10
+ if (e.headers.get("x-nuxt-seo-redirected")) {
11
+ return;
12
+ }
13
+ if (originHostname !== siteConfigHostName && originHostname !== new URL(e.path, origin).hostname) {
14
+ setHeader(e, "x-nuxt-seo-redirected", "true");
15
+ return sendRedirect(e, joinURL(siteConfig.url, e.path), 301);
16
+ }
17
+ }
18
+ });
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "../../../.nuxt/tsconfig.server.json"
3
+ }
@@ -0,0 +1,10 @@
1
+ export declare function useSchemaOrg(): void;
2
+ export declare function defineWebSite(): void;
3
+ export declare function defineWebPage(): void;
4
+ export declare function useI18n(): {
5
+ t: (_: string, fallback: string) => string;
6
+ te: (_: string) => boolean;
7
+ strategy: string;
8
+ defaultLocale: import("#imports").Ref<any>;
9
+ locale: import("#imports").Ref<any>;
10
+ };
@@ -0,0 +1,18 @@
1
+ import { ref } from "vue";
2
+ import { useSiteConfig } from "#imports";
3
+ export function useSchemaOrg() {
4
+ }
5
+ export function defineWebSite() {
6
+ }
7
+ export function defineWebPage() {
8
+ }
9
+ export function useI18n() {
10
+ const siteConfig = useSiteConfig();
11
+ return {
12
+ t: (_, fallback) => fallback,
13
+ te: (_) => false,
14
+ strategy: "no_prefix",
15
+ defaultLocale: ref(siteConfig.defaultLocale || "en"),
16
+ locale: ref(siteConfig.currentLocale || siteConfig.defaultLocale || "en")
17
+ };
18
+ }
@@ -0,0 +1,86 @@
1
+ import type { MaybeRefOrGetter } from 'vue';
2
+ import type { NuxtLinkProps } from 'nuxt/app';
3
+ interface NuxtUIBreadcrumbItem extends NuxtLinkProps {
4
+ label: string;
5
+ labelClass?: string;
6
+ icon?: string;
7
+ iconClass?: string;
8
+ as?: string;
9
+ type?: string;
10
+ disabled?: boolean;
11
+ active?: boolean;
12
+ exact?: boolean;
13
+ exactQuery?: boolean;
14
+ exactMatch?: boolean;
15
+ inactiveClass?: string;
16
+ [key: string]: any;
17
+ }
18
+ export interface BreadcrumbProps {
19
+ /**
20
+ * Generate the breadcrumbs based on a different path than the current route.
21
+ */
22
+ path?: MaybeRefOrGetter<string>;
23
+ /**
24
+ * The id of the breadcrumb list. It's recommended to provide a unique
25
+ * id when adding multiple breadcrumb lists to the same page.
26
+ */
27
+ id?: string;
28
+ /**
29
+ * Append additional breadcrumb items to the end of the list. This is applied
30
+ * after the `overrides` option.
31
+ */
32
+ append?: BreadcrumbItemProps[];
33
+ /**
34
+ * Prepend additional breadcrumb items to the start of the list. This is applied
35
+ * after the `overrides` option.
36
+ */
37
+ prepend?: BreadcrumbItemProps[];
38
+ /**
39
+ * Override any of the breadcrumb items based on the index.
40
+ */
41
+ overrides?: (BreadcrumbItemProps | false | undefined)[];
42
+ /**
43
+ * Should the schema.org breadcrumb be generated.
44
+ * @default true
45
+ */
46
+ schemaOrg?: boolean;
47
+ /**
48
+ * The Aria Label for the breadcrumbs.
49
+ * You shouldn't need to change this.
50
+ *
51
+ * @default 'Breadcrumbs'
52
+ */
53
+ ariaLabel?: string;
54
+ /**
55
+ * Should the current breadcrumb item be shown.
56
+ *
57
+ * @default false
58
+ */
59
+ hideCurrent?: MaybeRefOrGetter<boolean>;
60
+ /**
61
+ * Should the root breadcrumb be shown.
62
+ */
63
+ hideRoot?: MaybeRefOrGetter<boolean>;
64
+ }
65
+ export interface BreadcrumbItemProps extends NuxtUIBreadcrumbItem {
66
+ /** Whether the breadcrumb item represents the aria-current. */
67
+ current?: boolean;
68
+ /**
69
+ * The type of current location the breadcrumb item represents, if `isCurrent` is true.
70
+ * @default 'page'
71
+ */
72
+ ariaCurrent?: 'page' | 'step' | 'location' | 'date' | 'time' | boolean | 'true' | 'false';
73
+ to?: string;
74
+ ariaLabel?: string;
75
+ separator?: boolean | string;
76
+ class?: (string | string[] | undefined)[] | string;
77
+ /**
78
+ * @internal
79
+ */
80
+ _props?: {
81
+ first: boolean;
82
+ last: boolean;
83
+ };
84
+ }
85
+ export declare function useBreadcrumbItems(options?: BreadcrumbProps): import("#imports").ComputedRef<BreadcrumbItemProps[]>;
86
+ export {};
@@ -0,0 +1,99 @@
1
+ import { withoutTrailingSlash } from "ufo";
2
+ import { defu } from "defu";
3
+ import { pathBreadcrumbSegments } from "../../pure/breadcrumbs.js";
4
+ import {
5
+ computed,
6
+ createSitePathResolver,
7
+ defineBreadcrumb,
8
+ toValue,
9
+ useI18n,
10
+ useRoute,
11
+ useRouter,
12
+ useSchemaOrg,
13
+ withSiteTrailingSlash
14
+ } from "#imports";
15
+ function withoutQuery(path) {
16
+ return path.split("?")[0];
17
+ }
18
+ function titleCase(s) {
19
+ return s.replaceAll("-", " ").replace(/\w\S*/g, (w) => w.charAt(0).toUpperCase() + w.substr(1).toLowerCase());
20
+ }
21
+ export function useBreadcrumbItems(options = {}) {
22
+ const router = useRouter();
23
+ const routes = router.getRoutes();
24
+ const i18n = useI18n();
25
+ const siteResolver = createSitePathResolver({
26
+ canonical: true,
27
+ absolute: true
28
+ });
29
+ const items = computed(() => {
30
+ let rootNode = "/";
31
+ if (i18n) {
32
+ if (i18n.strategy === "prefix" || i18n.strategy !== "no_prefix" && toValue(i18n.defaultLocale) !== toValue(i18n.locale))
33
+ rootNode = `/${toValue(i18n.locale)}`;
34
+ }
35
+ const current = withoutQuery(withoutTrailingSlash(toValue(options.path || useRoute().path) || rootNode));
36
+ const overrides = options.overrides || [];
37
+ const segments = pathBreadcrumbSegments(current, rootNode).map((path, index) => {
38
+ let item = {
39
+ to: path
40
+ };
41
+ if (typeof overrides[index] !== "undefined") {
42
+ if (overrides[index] === false)
43
+ return false;
44
+ item = defu(overrides[index], item);
45
+ }
46
+ return item;
47
+ });
48
+ if (options.prepend)
49
+ segments.unshift(...options.prepend);
50
+ if (options.append)
51
+ segments.push(...options.append);
52
+ return segments.filter(Boolean).map((item) => {
53
+ const route = routes.find((r) => withoutTrailingSlash(r.path) === withoutTrailingSlash(item.to));
54
+ const routeMeta = route?.meta || {};
55
+ const routeName = route ? String(route.name || route.path) : item.to === "/" ? "index" : "unknown";
56
+ let [name] = routeName.split("___");
57
+ if (name === "unknown")
58
+ name = (item.to || "").split("/").pop() || "";
59
+ if (routeMeta.breadcrumb) {
60
+ item = {
61
+ ...item,
62
+ ...routeMeta.breadcrumb
63
+ };
64
+ }
65
+ item.label = item.label || routeMeta.breadcrumbTitle || routeMeta.title;
66
+ if (typeof item.label === "undefined") {
67
+ item.label = item.label || i18n.t(`breadcrumb.items.${name}.label`, name === "index" ? "Home" : titleCase(name), { missingWarn: false });
68
+ item.ariaLabel = item.ariaLabel || i18n.t(`breadcrumb.items.${name}.ariaLabel`, item.label, { missingWarn: false });
69
+ }
70
+ item.ariaLabel = item.ariaLabel || item.label;
71
+ item.current = item.current || item.to === current;
72
+ if (toValue(options.hideCurrent) && item.current)
73
+ return false;
74
+ return item;
75
+ }).map((m) => {
76
+ if (m && m.to) {
77
+ m.to = withSiteTrailingSlash(m.to).value;
78
+ if (m.to === rootNode && toValue(options.hideRoot))
79
+ return false;
80
+ }
81
+ return m;
82
+ }).filter(Boolean);
83
+ });
84
+ const schemaOrgEnabled = typeof options.schemaOrg === "undefined" ? true : options.schemaOrg;
85
+ if (import.meta.server && schemaOrgEnabled) {
86
+ useSchemaOrg([
87
+ defineBreadcrumb(computed(() => {
88
+ return {
89
+ id: `#${options.id || "breadcrumb"}`,
90
+ itemListElement: items.value.map((item) => ({
91
+ name: item.label || item.ariaLabel,
92
+ item: item.to ? siteResolver(item.to) : void 0
93
+ }))
94
+ };
95
+ }))
96
+ ]);
97
+ }
98
+ return items;
99
+ }
@@ -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
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,11 @@
1
+ import { applyDefaults as setup } from "../logic/applyDefaults.js";
2
+ import {
3
+ defineNuxtPlugin
4
+ } from "#imports";
5
+ export default defineNuxtPlugin({
6
+ name: "nuxt-seo:defaults",
7
+ env: {
8
+ islands: false
9
+ },
10
+ setup
11
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,14 @@
1
+ import { applyDefaults as setup } from "../logic/applyDefaults.js";
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
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,31 @@
1
+ import { withoutTrailingSlash } from "ufo";
2
+ import {
3
+ computed,
4
+ defineNuxtPlugin,
5
+ useHead,
6
+ useRoute
7
+ } from "#imports";
8
+ function titleCase(s) {
9
+ return s.replaceAll("-", " ").replace(/\w\S*/g, (w) => w.charAt(0).toUpperCase() + w.substr(1).toLowerCase());
10
+ }
11
+ export default defineNuxtPlugin({
12
+ name: "nuxt-seo:fallback-titles",
13
+ env: {
14
+ islands: false
15
+ },
16
+ setup() {
17
+ const route = useRoute();
18
+ const title = computed(() => {
19
+ if (typeof route.meta?.title === "string")
20
+ return route.meta?.title;
21
+ const path = withoutTrailingSlash(route.path || "/");
22
+ const lastSegment = path.split("/").pop();
23
+ return lastSegment ? titleCase(lastSegment) : null;
24
+ });
25
+ const minimalPriority = {
26
+ // give nuxt.config values higher priority
27
+ tagPriority: 101
28
+ };
29
+ useHead({ title: () => title.value }, minimalPriority);
30
+ }
31
+ });
@@ -0,0 +1 @@
1
+ export declare function pathBreadcrumbSegments(path: string, rootNode?: string): string[];
@@ -0,0 +1,18 @@
1
+ import { hasTrailingSlash, parseURL, stringifyParsedURL, withTrailingSlash } from "ufo";
2
+ export function pathBreadcrumbSegments(path, rootNode = "/") {
3
+ const startNode = parseURL(path);
4
+ const appendsTrailingSlash = hasTrailingSlash(startNode.pathname);
5
+ const stepNode = (node, nodes = []) => {
6
+ const fullPath = stringifyParsedURL(node);
7
+ const currentPathName = node.pathname || "/";
8
+ nodes.push(fullPath || "/");
9
+ if (currentPathName !== rootNode && currentPathName !== "/") {
10
+ node.pathname = currentPathName.substring(0, currentPathName.lastIndexOf("/"));
11
+ if (appendsTrailingSlash)
12
+ node.pathname = withTrailingSlash(node.pathname.substring(0, node.pathname.lastIndexOf("/")));
13
+ stepNode(node, nodes);
14
+ }
15
+ return nodes;
16
+ };
17
+ return stepNode(startNode).reverse();
18
+ }
package/dist/types.d.mts CHANGED
@@ -1,19 +1 @@
1
- import type { ModuleHooks, ModuleRuntimeHooks, ModuleRuntimeConfig, ModulePublicRuntimeConfig } from './module.js'
2
-
3
- declare module '#app' {
4
- interface RuntimeNuxtHooks extends ModuleRuntimeHooks {}
5
- }
6
-
7
- declare module '@nuxt/schema' {
8
- interface NuxtHooks extends ModuleHooks {}
9
- interface RuntimeConfig extends ModuleRuntimeConfig {}
10
- interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
11
- }
12
-
13
- declare module 'nuxt/schema' {
14
- interface NuxtHooks extends ModuleHooks {}
15
- interface RuntimeConfig extends ModuleRuntimeConfig {}
16
- interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
17
- }
18
-
19
- export * from "./module.js"
1
+ export { type ModuleOptions, default } from './module.js'
package/dist/types.d.ts CHANGED
@@ -1,19 +1 @@
1
- import type { ModuleHooks, ModuleRuntimeHooks, ModuleRuntimeConfig, ModulePublicRuntimeConfig } from './module'
2
-
3
- declare module '#app' {
4
- interface RuntimeNuxtHooks extends ModuleRuntimeHooks {}
5
- }
6
-
7
- declare module '@nuxt/schema' {
8
- interface NuxtHooks extends ModuleHooks {}
9
- interface RuntimeConfig extends ModuleRuntimeConfig {}
10
- interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
11
- }
12
-
13
- declare module 'nuxt/schema' {
14
- interface NuxtHooks extends ModuleHooks {}
15
- interface RuntimeConfig extends ModuleRuntimeConfig {}
16
- interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
17
- }
18
-
19
- export * from "./module"
1
+ export { type ModuleOptions, default } from './module'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nuxtjs/seo",
3
3
  "type": "module",
4
- "version": "2.0.0-rc.13",
4
+ "version": "2.0.0-rc.15",
5
5
  "description": "The all-in-one SEO layer for Nuxt 3.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -32,20 +32,20 @@
32
32
  ],
33
33
  "dependencies": {
34
34
  "@nuxt/kit": "^3.12.3",
35
- "@nuxtjs/robots": "^4.0.0-rc.22",
36
- "@nuxtjs/sitemap": "^5.3.4",
35
+ "@nuxtjs/robots": "^4.0.1",
36
+ "@nuxtjs/sitemap": "^5.3.5",
37
37
  "defu": "^6.1.4",
38
- "nuxt-link-checker": "^3.0.0-rc.12",
39
- "nuxt-og-image": "^3.0.0-rc.61",
40
- "nuxt-schema-org": "^3.3.8",
41
- "nuxt-seo-experiments": "^4.0.0-rc.13",
42
- "nuxt-site-config": "^2.2.14",
43
- "nuxt-site-config-kit": "^2.2.14",
38
+ "nuxt-link-checker": "^3.0.2",
39
+ "nuxt-og-image": "^3.0.0-rc.63",
40
+ "nuxt-schema-org": "^3.3.9",
41
+ "nuxt-seo-experiments": "^4.0.0",
42
+ "nuxt-site-config": "^2.2.15",
43
+ "nuxt-site-config-kit": "^2.2.15",
44
44
  "pkg-types": "^1.1.3",
45
45
  "ufo": "^1.5.3"
46
46
  },
47
47
  "devDependencies": {
48
- "@antfu/eslint-config": "^2.22.2",
48
+ "@antfu/eslint-config": "^2.22.4",
49
49
  "@nuxt/module-builder": "^0.8.1",
50
50
  "@nuxt/schema": "^3.12.3",
51
51
  "@nuxt/test-utils": "3.13.1",
@@ -59,9 +59,6 @@
59
59
  "typescript": "5.4.5",
60
60
  "vitest": "^2.0.3"
61
61
  },
62
- "resolutions": {
63
- "shiki": "1.10.1"
64
- },
65
62
  "build": {
66
63
  "externals": [
67
64
  "ofetch",