nuxt-seo-utils 5.0.2 → 6.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/LICENSE.md +9 -0
- package/README.md +30 -17
- package/dist/module.d.mts +5 -0
- package/dist/module.d.ts +5 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +27 -22
- package/dist/runtime/{nuxt → app}/composables/useBreadcrumbItems.js +4 -5
- package/dist/runtime/{nuxt → app}/logic/applyDefaults.js +4 -6
- package/dist/runtime/{nuxt → app}/plugins/0.routeRules.server.js +1 -2
- package/dist/runtime/{nuxt → app}/plugins/1.absoluteImageUrls.server.js +2 -1
- package/dist/runtime/{nuxt → app}/plugins/defaults.js +2 -2
- package/dist/runtime/{nuxt → app}/plugins/defaultsWaitI18n.js +3 -1
- package/dist/runtime/{nuxt → app}/plugins/titles.js +3 -6
- package/dist/runtime/{nitro/middleware/redirectNitroOrigin.js → server/middleware/redirectCanonical.js} +5 -6
- package/dist/runtime/server/middleware/resolveImagesInPagesDir.d.ts +2 -0
- package/dist/runtime/{nitro/middleware/resolveImagesInPagesDir.dev.js → server/middleware/resolveImagesInPagesDir.js} +2 -3
- package/package.json +21 -17
- package/dist/runtime/nitro/middleware/resolveImagesInPagesDir.dev.d.ts +0 -2
- /package/dist/runtime/{nuxt → app}/composables/polyfills.d.ts +0 -0
- /package/dist/runtime/{nuxt → app}/composables/polyfills.js +0 -0
- /package/dist/runtime/{nuxt → app}/composables/useBreadcrumbItems.d.ts +0 -0
- /package/dist/runtime/{nuxt → app}/logic/applyDefaults.d.ts +0 -0
- /package/dist/runtime/{nuxt → app}/plugins/0.routeRules.server.d.ts +0 -0
- /package/dist/runtime/{nuxt → app}/plugins/1.absoluteImageUrls.server.d.ts +0 -0
- /package/dist/runtime/{nuxt → app}/plugins/defaults.d.ts +0 -0
- /package/dist/runtime/{nuxt → app}/plugins/defaultsWaitI18n.d.ts +0 -0
- /package/dist/runtime/{nuxt → app}/plugins/inferSeoMetaPlugin.d.ts +0 -0
- /package/dist/runtime/{nuxt → app}/plugins/inferSeoMetaPlugin.js +0 -0
- /package/dist/runtime/{nuxt → app}/plugins/siteConfig.d.ts +0 -0
- /package/dist/runtime/{nuxt → app}/plugins/siteConfig.js +0 -0
- /package/dist/runtime/{nuxt → app}/plugins/titles.d.ts +0 -0
- /package/dist/runtime/{nitro/middleware/redirectNitroOrigin.d.ts → server/middleware/redirectCanonical.d.ts} +0 -0
- /package/dist/runtime/{nitro → server}/tsconfig.json +0 -0
- /package/dist/runtime/{pure → shared}/breadcrumbs.d.ts +0 -0
- /package/dist/runtime/{pure → shared}/breadcrumbs.js +0 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Harlan Wilton
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
|
-
<h1
|
|
1
|
+
<h1>nuxt-seo-utils</h1>
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
<a href="https://www.npmjs.com/package/nuxt-seo-utils" target="__blank"><img alt="NPM Downloads" src="https://img.shields.io/npm/dm/nuxt-seo-utils?flat&colorA=002438&colorB=28CF8D"></a>
|
|
8
|
-
<a href="https://github.com/harlan-zw/nuxt-seo-utils" target="__blank"><img alt="GitHub stars" src="https://img.shields.io/github/stars/harlan-zw/nuxt-seo-utils?flat&colorA=002438&colorB=28CF8D"></a>
|
|
9
|
-
</p>
|
|
3
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
4
|
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
5
|
+
[![License][license-src]][license-href]
|
|
6
|
+
[![Nuxt][nuxt-src]][nuxt-href]
|
|
10
7
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
Nuxt SEO Utils is a collection of defaults and utilities to improve your Nuxt site's discoverability and shareability.
|
|
9
|
+
|
|
10
|
+
While there are several features covering many aspects of SEO, it covers important defaults such as [automatic canonical URLs](https://nuxtseo.com/learn/controlling-crawlers/canonical-urls) and
|
|
11
|
+
[open graph tags](https://nuxtseo.com/learn/mastering-meta/open-graph).
|
|
14
12
|
|
|
15
13
|
<p align="center">
|
|
16
14
|
<table>
|
|
17
15
|
<tbody>
|
|
18
16
|
<td align="center">
|
|
19
|
-
<img width="800" height="0" /><br>
|
|
20
|
-
<i>Status:</i> <a href="https://github.com/harlan-zw/nuxt-seo-utils/releases/tag/v3.0.0">v3 Released</a> <br>
|
|
21
|
-
<sup> Please report any issues 🐛</sup><br>
|
|
22
17
|
<sub>Made possible by my <a href="https://github.com/sponsors/harlan-zw">Sponsor Program 💖</a><br> Follow me <a href="https://twitter.com/harlan_zw">@harlan_zw</a> 🐦 • Join <a href="https://discord.gg/275MBUBvgP">Discord</a> for help</sub><br>
|
|
23
|
-
<img width="800" height="0" />
|
|
24
18
|
</td>
|
|
25
19
|
</tbody>
|
|
26
20
|
</table>
|
|
@@ -44,10 +38,16 @@ Install `nuxt-seo-utils` dependency to your project:
|
|
|
44
38
|
npx nuxi@latest module add nuxt-seo-utils
|
|
45
39
|
```
|
|
46
40
|
|
|
47
|
-
|
|
41
|
+
💡 Need a complete SEO solution for Nuxt? Check out [Nuxt SEO](https://nuxtseo.com).
|
|
42
|
+
|
|
43
|
+
## Documentation
|
|
48
44
|
|
|
49
45
|
[📖 Read the full documentation](https://nuxtseo.com/docs/utils) for more information.
|
|
50
46
|
|
|
47
|
+
## Demos
|
|
48
|
+
|
|
49
|
+
[Basic](https://stackblitz.com/edit/nuxt-starter-vbay3q?file=app.vue)
|
|
50
|
+
|
|
51
51
|
## Sponsors
|
|
52
52
|
|
|
53
53
|
<p align="center">
|
|
@@ -58,4 +58,17 @@ npx nuxi@latest module add nuxt-seo-utils
|
|
|
58
58
|
|
|
59
59
|
## License
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
Licensed under the [MIT license](https://github.com/harlan-zw/nuxt-seo-utils/blob/main/LICENSE.md).
|
|
62
|
+
|
|
63
|
+
<!-- Badges -->
|
|
64
|
+
[npm-version-src]: https://img.shields.io/npm/v/nuxt-seo-utils/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
|
|
65
|
+
[npm-version-href]: https://npmjs.com/package/nuxt-seo-utils
|
|
66
|
+
|
|
67
|
+
[npm-downloads-src]: https://img.shields.io/npm/dm/nuxt-seo-utils.svg?style=flat&colorA=18181B&colorB=28CF8D
|
|
68
|
+
[npm-downloads-href]: https://npmjs.com/package/nuxt-seo-utils
|
|
69
|
+
|
|
70
|
+
[license-src]: https://img.shields.io/github/license/harlan-zw/nuxt-seo-utils.svg?style=flat&colorA=18181B&colorB=28CF8D
|
|
71
|
+
[license-href]: https://github.com/harlan-zw/nuxt-seo-utils/blob/main/LICENSE.md
|
|
72
|
+
|
|
73
|
+
[nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt.js
|
|
74
|
+
[nuxt-href]: https://nuxt.com
|
package/dist/module.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { UseSeoMetaInput } from '@unhead/schema';
|
|
2
3
|
|
|
3
4
|
interface ModuleOptions {
|
|
4
5
|
/**
|
|
@@ -91,6 +92,10 @@ interface ModuleOptions {
|
|
|
91
92
|
* @default false
|
|
92
93
|
*/
|
|
93
94
|
redirectToCanonicalSiteUrl?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* The SEO meta object to be used as defaults.
|
|
97
|
+
*/
|
|
98
|
+
meta: UseSeoMetaInput;
|
|
94
99
|
/**
|
|
95
100
|
* Enables debug logs and a debug endpoint.
|
|
96
101
|
*
|
package/dist/module.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { UseSeoMetaInput } from '@unhead/schema';
|
|
2
3
|
|
|
3
4
|
interface ModuleOptions {
|
|
4
5
|
/**
|
|
@@ -91,6 +92,10 @@ interface ModuleOptions {
|
|
|
91
92
|
* @default false
|
|
92
93
|
*/
|
|
93
94
|
redirectToCanonicalSiteUrl?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* The SEO meta object to be used as defaults.
|
|
97
|
+
*/
|
|
98
|
+
meta: UseSeoMetaInput;
|
|
94
99
|
/**
|
|
95
100
|
* Enables debug logs and a debug endpoint.
|
|
96
101
|
*
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { useNuxt, createResolver, addTemplate, defineNuxtModule, useLogger, addServerHandler, hasNuxtModule, addPlugin, addImports, addVitePlugin } from '@nuxt/kit';
|
|
2
2
|
import UnheadVite from '@unhead/addons/vite';
|
|
3
|
-
import {
|
|
3
|
+
import { defu } from 'defu';
|
|
4
|
+
import { resolvePath } from 'mlly';
|
|
5
|
+
import { installNuxtSiteConfig } from 'nuxt-site-config/kit';
|
|
6
|
+
import { relative, resolve, extname, dirname, basename } from 'pathe';
|
|
4
7
|
import { unpackMeta } from '@unhead/shared';
|
|
5
8
|
import fg from 'fast-glob';
|
|
6
|
-
import { relative, resolve, extname, dirname, basename } from 'pathe';
|
|
7
9
|
import fs from 'node:fs';
|
|
8
|
-
import { defu } from 'defu';
|
|
9
10
|
import { encodePath, joinURL } from 'ufo';
|
|
10
11
|
import escapeRE from 'escape-string-regexp';
|
|
11
12
|
import { readFile } from 'node:fs/promises';
|
|
@@ -13,6 +14,7 @@ import imageSize from 'image-size';
|
|
|
13
14
|
|
|
14
15
|
function extendNuxtConfigAppHeadSeoMeta(nuxt = useNuxt()) {
|
|
15
16
|
const seoMeta = nuxt.options.app?.seoMeta || nuxt.options.app?.head?.seoMeta || false;
|
|
17
|
+
const configSeoMeta = nuxt.options.seo?.meta || false;
|
|
16
18
|
if (!seoMeta)
|
|
17
19
|
return;
|
|
18
20
|
nuxt.options.app.head = nuxt.options.app.head || {};
|
|
@@ -20,10 +22,12 @@ function extendNuxtConfigAppHeadSeoMeta(nuxt = useNuxt()) {
|
|
|
20
22
|
...nuxt.options.app.head,
|
|
21
23
|
meta: [
|
|
22
24
|
...nuxt.options.app.head.meta || [],
|
|
23
|
-
...unpackMeta(seoMeta)
|
|
25
|
+
...unpackMeta(seoMeta),
|
|
26
|
+
...unpackMeta(configSeoMeta)
|
|
24
27
|
]
|
|
25
28
|
};
|
|
26
29
|
delete nuxt.options.app.seoMeta;
|
|
30
|
+
delete nuxt.options.app.head.seoMeta;
|
|
27
31
|
return nuxt.options.app.head;
|
|
28
32
|
}
|
|
29
33
|
|
|
@@ -268,7 +272,7 @@ async function generateTagsFromPageDirImages(nuxt = useNuxt()) {
|
|
|
268
272
|
nuxt.options.nitro.routeRules = defu(appendRouteRules, nuxt.options.nitro.routeRules);
|
|
269
273
|
if (nuxt.options.dev) {
|
|
270
274
|
nuxt.hooks.hook("nitro:config", async (nitroConfig) => {
|
|
271
|
-
nitroConfig.virtual["#
|
|
275
|
+
nitroConfig.virtual["#seo-utils-virtual/pageDirImages"] = `export const fileMapping = ${JSON.stringify(devMiddlewareMap)}`;
|
|
272
276
|
});
|
|
273
277
|
}
|
|
274
278
|
nuxt.hooks.hook("nitro:build:public-assets", (_nitro) => {
|
|
@@ -423,7 +427,7 @@ const module = defineNuxtModule({
|
|
|
423
427
|
if (nuxt.options.dev) {
|
|
424
428
|
addServerHandler({
|
|
425
429
|
middleware: true,
|
|
426
|
-
handler: resolve("runtime/
|
|
430
|
+
handler: resolve("./runtime/server/middleware/resolveImagesInPagesDir")
|
|
427
431
|
});
|
|
428
432
|
}
|
|
429
433
|
}
|
|
@@ -431,27 +435,27 @@ const module = defineNuxtModule({
|
|
|
431
435
|
if (config.automaticDefaults) {
|
|
432
436
|
if (hasI18n) {
|
|
433
437
|
addPlugin({
|
|
434
|
-
src: resolve(`./runtime/
|
|
438
|
+
src: resolve(`./runtime/app/plugins/defaultsWaitI18n`)
|
|
435
439
|
});
|
|
436
440
|
} else {
|
|
437
441
|
addPlugin({
|
|
438
|
-
src: resolve(`./runtime/
|
|
442
|
+
src: resolve(`./runtime/app/plugins/defaults`)
|
|
439
443
|
});
|
|
440
444
|
}
|
|
441
445
|
}
|
|
442
446
|
if (config.fallbackTitle) {
|
|
443
447
|
addPlugin({
|
|
444
|
-
src: resolve("./runtime/
|
|
448
|
+
src: resolve("./runtime/app/plugins/titles")
|
|
445
449
|
});
|
|
446
450
|
}
|
|
447
451
|
if (!hasI18n) {
|
|
448
452
|
addImports({
|
|
449
|
-
from: resolve(`./runtime/
|
|
453
|
+
from: resolve(`./runtime/app/composables/polyfills`),
|
|
450
454
|
name: "useI18n"
|
|
451
455
|
});
|
|
452
456
|
}
|
|
453
457
|
addImports({
|
|
454
|
-
from: resolve(`./runtime/
|
|
458
|
+
from: resolve(`./runtime/app/composables/useBreadcrumbItems`),
|
|
455
459
|
name: "useBreadcrumbItems"
|
|
456
460
|
});
|
|
457
461
|
const polyfills = [
|
|
@@ -465,19 +469,19 @@ const module = defineNuxtModule({
|
|
|
465
469
|
];
|
|
466
470
|
polyfills.forEach((name) => {
|
|
467
471
|
addImports({
|
|
468
|
-
from: resolve("./runtime/
|
|
472
|
+
from: resolve("./runtime/app/composables/polyfills"),
|
|
469
473
|
name
|
|
470
474
|
});
|
|
471
475
|
});
|
|
472
476
|
nuxt.options.experimental.headNext = true;
|
|
473
477
|
if (!nuxt.options.dev && config.redirectToCanonicalSiteUrl) {
|
|
474
478
|
addServerHandler({
|
|
475
|
-
handler: resolve("./runtime/
|
|
479
|
+
handler: resolve("./runtime/server/middleware/redirectCanonical"),
|
|
476
480
|
middleware: true
|
|
477
481
|
});
|
|
478
482
|
}
|
|
479
483
|
nuxt.options.alias["#seo-utils"] = resolve("./runtime");
|
|
480
|
-
nuxt.options.runtimeConfig.public["
|
|
484
|
+
nuxt.options.runtimeConfig.public["seo-utils"] = defu(nuxt.options.runtimeConfig.public["seo-utils"] || {}, {
|
|
481
485
|
canonicalQueryWhitelist: config.canonicalQueryWhitelist || [
|
|
482
486
|
"page",
|
|
483
487
|
"sort",
|
|
@@ -487,7 +491,7 @@ const module = defineNuxtModule({
|
|
|
487
491
|
"category",
|
|
488
492
|
"tag"
|
|
489
493
|
]
|
|
490
|
-
};
|
|
494
|
+
});
|
|
491
495
|
if (config.extendNuxtConfigAppHeadSeoMeta)
|
|
492
496
|
extendNuxtConfigAppHeadSeoMeta();
|
|
493
497
|
if (config.setupNuxtConfigAppHeadWithMoreDefaults)
|
|
@@ -495,28 +499,29 @@ const module = defineNuxtModule({
|
|
|
495
499
|
if (config.extendNuxtConfigAppHeadTypes)
|
|
496
500
|
extendNuxtConfigAppHeadTypes();
|
|
497
501
|
extendTypes("nuxt-seo-utils", async () => {
|
|
502
|
+
const unheadSchemaPath = relative(resolve(nuxt.options.rootDir, nuxt.options.buildDir, "module"), await resolvePath("@unhead/schema"));
|
|
498
503
|
return `
|
|
499
504
|
declare module 'nitropack' {
|
|
500
505
|
interface NitroRouteRules {
|
|
501
|
-
seoMeta?: import('
|
|
502
|
-
head?: import('
|
|
506
|
+
seoMeta?: import('${unheadSchemaPath}').UseSeoMetaInput
|
|
507
|
+
head?: import('${unheadSchemaPath}').Head
|
|
503
508
|
}
|
|
504
509
|
interface NitroRouteConfig {
|
|
505
|
-
seoMeta?: import('
|
|
506
|
-
head?: import('
|
|
510
|
+
seoMeta?: import('${unheadSchemaPath}').UseSeoMetaInput
|
|
511
|
+
head?: import('${unheadSchemaPath}').Head
|
|
507
512
|
}
|
|
508
513
|
}
|
|
509
514
|
|
|
510
515
|
declare module '@nuxt/schema' {
|
|
511
|
-
interface
|
|
516
|
+
interface AppHeadMetaObject { seoMeta?: import('${unheadSchemaPath}').UseSeoMetaInput }
|
|
512
517
|
}
|
|
513
518
|
|
|
514
519
|
declare module 'nuxt/schema' {
|
|
515
|
-
interface
|
|
520
|
+
interface AppHeadMetaObject { seoMeta?: import('${unheadSchemaPath}').UseSeoMetaInput }
|
|
516
521
|
}
|
|
517
522
|
`;
|
|
518
523
|
});
|
|
519
|
-
const runtimeDir = resolve("./runtime/
|
|
524
|
+
const runtimeDir = resolve("./runtime/app");
|
|
520
525
|
if (config.treeShakeUseSeoMeta)
|
|
521
526
|
addVitePlugin(UnheadVite());
|
|
522
527
|
if (config.automaticOgAndTwitterTags)
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
-
computed,
|
|
3
2
|
createSitePathResolver,
|
|
4
3
|
defineBreadcrumb,
|
|
5
|
-
toValue,
|
|
6
4
|
useI18n,
|
|
7
|
-
useRouter,
|
|
8
5
|
useSchemaOrg,
|
|
9
6
|
useSiteConfig
|
|
10
7
|
} from "#imports";
|
|
11
8
|
import { defu } from "defu";
|
|
12
|
-
import {
|
|
9
|
+
import { useRouter } from "nuxt/app";
|
|
10
|
+
import { fixSlashes } from "nuxt-site-config/urls";
|
|
13
11
|
import { withoutTrailingSlash } from "ufo";
|
|
14
|
-
import {
|
|
12
|
+
import { computed, toValue } from "vue";
|
|
13
|
+
import { pathBreadcrumbSegments } from "../../shared/breadcrumbs.js";
|
|
15
14
|
function withoutQuery(path) {
|
|
16
15
|
return path.split("?")[0];
|
|
17
16
|
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
-
computed,
|
|
3
2
|
createSitePathResolver,
|
|
4
|
-
useHead,
|
|
5
|
-
useRoute,
|
|
6
|
-
useRuntimeConfig,
|
|
7
|
-
useSeoMeta,
|
|
8
3
|
useSiteConfig
|
|
9
4
|
} from "#imports";
|
|
5
|
+
import { useHead, useSeoMeta } from "@unhead/vue";
|
|
6
|
+
import { useRoute, useRuntimeConfig } from "nuxt/app";
|
|
10
7
|
import { stringifyQuery } from "ufo";
|
|
8
|
+
import { computed } from "vue";
|
|
11
9
|
export function applyDefaults(i18n) {
|
|
12
|
-
const { canonicalQueryWhitelist } = useRuntimeConfig().public["
|
|
10
|
+
const { canonicalQueryWhitelist } = useRuntimeConfig().public["seo-utils"];
|
|
13
11
|
const siteConfig = useSiteConfig();
|
|
14
12
|
const route = useRoute();
|
|
15
13
|
const resolveUrl = createSitePathResolver({ withBase: true, absolute: true });
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { useRequestEvent } from "#imports";
|
|
2
1
|
import { unpackMeta } from "@unhead/shared";
|
|
3
2
|
import { injectHead } from "@unhead/vue";
|
|
4
|
-
import { defineNuxtPlugin } from "nuxt/app";
|
|
3
|
+
import { defineNuxtPlugin, useRequestEvent } from "nuxt/app";
|
|
5
4
|
export default defineNuxtPlugin({
|
|
6
5
|
enforce: "post",
|
|
7
6
|
async setup() {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { createSitePathResolver
|
|
1
|
+
import { createSitePathResolver } from "#imports";
|
|
2
2
|
import { injectHead } from "@unhead/vue";
|
|
3
3
|
import { defineNuxtPlugin } from "nuxt/app";
|
|
4
|
+
import { unref } from "vue";
|
|
4
5
|
export default defineNuxtPlugin({
|
|
5
6
|
enforce: "post",
|
|
6
7
|
setup() {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
defineNuxtPlugin,
|
|
3
|
-
ref,
|
|
4
2
|
useSiteConfig
|
|
5
3
|
} from "#imports";
|
|
4
|
+
import { defineNuxtPlugin } from "nuxt/app";
|
|
5
|
+
import { ref } from "vue";
|
|
6
6
|
import { applyDefaults } from "../logic/applyDefaults.js";
|
|
7
7
|
export default defineNuxtPlugin({
|
|
8
8
|
name: "nuxt-seo:defaults",
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useSiteConfig } from "#imports";
|
|
2
|
+
import { defineNuxtPlugin } from "nuxt/app";
|
|
3
|
+
import { ref } from "vue";
|
|
2
4
|
import { applyDefaults } from "../logic/applyDefaults.js";
|
|
3
5
|
export default defineNuxtPlugin({
|
|
4
6
|
name: "nuxt-seo:defaults",
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
defineNuxtPlugin,
|
|
4
|
-
useHead,
|
|
5
|
-
useRoute
|
|
6
|
-
} from "#imports";
|
|
1
|
+
import { useHead } from "@unhead/vue";
|
|
2
|
+
import { defineNuxtPlugin, useRoute } from "nuxt/app";
|
|
7
3
|
import { titleCase } from "scule";
|
|
8
4
|
import { withoutTrailingSlash } from "ufo";
|
|
5
|
+
import { computed } from "vue";
|
|
9
6
|
export default defineNuxtPlugin({
|
|
10
7
|
name: "nuxt-seo:fallback-titles",
|
|
11
8
|
env: {
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { defineEventHandler, sendRedirect, setHeader } from "h3";
|
|
1
|
+
import { useSiteConfig } from "#site-config/server/composables/useSiteConfig";
|
|
2
|
+
import { defineEventHandler, getRequestHost, sendRedirect, setHeader } from "h3";
|
|
3
3
|
import { joinURL } from "ufo";
|
|
4
4
|
export default defineEventHandler((e) => {
|
|
5
5
|
const siteConfig = useSiteConfig(e);
|
|
6
6
|
if (siteConfig.url) {
|
|
7
|
-
const siteConfigHostName = new URL(e.path, siteConfig.url).
|
|
8
|
-
const
|
|
9
|
-
const originHostname = new URL(e.path, origin).hostname;
|
|
7
|
+
const siteConfigHostName = new URL(e.path, siteConfig.url).host;
|
|
8
|
+
const host = getRequestHost(e, { xForwardedHost: true });
|
|
10
9
|
if (e.headers.get("x-nuxt-seo-redirected")) {
|
|
11
10
|
return;
|
|
12
11
|
}
|
|
13
|
-
if (
|
|
12
|
+
if (host.split(":")[0] !== siteConfigHostName.split(":")[0]) {
|
|
14
13
|
setHeader(e, "x-nuxt-seo-redirected", "true");
|
|
15
14
|
return sendRedirect(e, joinURL(siteConfig.url, e.path), 301);
|
|
16
15
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { setHeader } from "h3";
|
|
2
|
+
import { fileMapping } from "#seo-utils-virtual/pageDirImages";
|
|
3
|
+
import { defineEventHandler, setHeader } from "h3";
|
|
5
4
|
import { parseURL } from "ufo";
|
|
6
5
|
export default defineEventHandler(async (e) => {
|
|
7
6
|
const path = parseURL(e.path).pathname;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-seo-utils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "6.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",
|
|
@@ -32,39 +32,43 @@
|
|
|
32
32
|
]
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@nuxt/kit": "^3.
|
|
36
|
-
"@unhead/addons": "^1.11.
|
|
35
|
+
"@nuxt/kit": "^3.14.1592",
|
|
36
|
+
"@unhead/addons": "^1.11.11",
|
|
37
|
+
"@unhead/schema": "^1.11.11",
|
|
37
38
|
"defu": "^6.1.4",
|
|
38
39
|
"escape-string-regexp": "^5.0.0",
|
|
39
40
|
"fast-glob": "^3.3.2",
|
|
40
41
|
"image-size": "^1.1.1",
|
|
41
|
-
"
|
|
42
|
-
"nuxt-site-config
|
|
42
|
+
"mlly": "^1.7.3",
|
|
43
|
+
"nuxt-site-config": "^3.0.3",
|
|
43
44
|
"pathe": "^1.1.2",
|
|
44
45
|
"scule": "^1.3.0",
|
|
45
46
|
"ufo": "^1.5.4"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
|
-
"@antfu/eslint-config": "3.
|
|
49
|
+
"@antfu/eslint-config": "3.9.2",
|
|
49
50
|
"@nuxt/module-builder": "^0.8.4",
|
|
50
51
|
"@nuxt/test-utils": "^3.14.4",
|
|
51
|
-
"@nuxt/ui": "^2.
|
|
52
|
+
"@nuxt/ui": "^2.19.2",
|
|
52
53
|
"@nuxtjs/eslint-config-typescript": "^12.1.0",
|
|
53
|
-
"@nuxtjs/i18n": "^
|
|
54
|
-
"@unhead/shared": "^1.11.
|
|
54
|
+
"@nuxtjs/i18n": "^9.1.0",
|
|
55
|
+
"@unhead/shared": "^1.11.11",
|
|
55
56
|
"@vue/test-utils": "^2.4.6",
|
|
56
|
-
"bumpp": "^9.8.
|
|
57
|
+
"bumpp": "^9.8.1",
|
|
57
58
|
"case-police": "^0.7.0",
|
|
58
59
|
"cheerio": "1.0.0",
|
|
59
|
-
"eslint": "^9.
|
|
60
|
-
"happy-dom": "^15.
|
|
61
|
-
"markdownlint-cli": "^0.
|
|
62
|
-
"nuxt": "^3.
|
|
60
|
+
"eslint": "^9.15.0",
|
|
61
|
+
"happy-dom": "^15.11.6",
|
|
62
|
+
"markdownlint-cli": "^0.43.0",
|
|
63
|
+
"nuxt": "^3.14.1592",
|
|
63
64
|
"nuxt-content-twoslash": "^0.1.1",
|
|
64
|
-
"playwright-core": "^1.
|
|
65
|
-
"sass": "^1.
|
|
65
|
+
"playwright-core": "^1.49.0",
|
|
66
|
+
"sass": "^1.81.0",
|
|
66
67
|
"typescript": "5.6.3",
|
|
67
|
-
"vitest": "^2.1.
|
|
68
|
+
"vitest": "^2.1.5"
|
|
69
|
+
},
|
|
70
|
+
"resolutions": {
|
|
71
|
+
"typescript": "5.6.3"
|
|
68
72
|
},
|
|
69
73
|
"scripts": {
|
|
70
74
|
"lint": "eslint . --fix",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|