nuxt-schema-org 2.2.0 → 3.0.0
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/README.md +68 -10
- package/dist/module.d.mts +38 -0
- package/dist/module.d.ts +30 -7
- package/dist/module.json +2 -2
- package/dist/module.mjs +19 -14
- package/dist/runtime/plugin.mjs +28 -18
- package/dist/types.d.mts +19 -0
- package/dist/types.d.ts +4 -2
- package/package.json +34 -21
package/README.md
CHANGED
|
@@ -1,21 +1,79 @@
|
|
|
1
|
-
|
|
1
|
+
<h1 align='center'>nuxt-schema-org</h1>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href='https://github.com/harlan-zw/nuxt-schema-org/actions/workflows/test.yml'>
|
|
5
|
+
</a>
|
|
6
|
+
<a href="https://www.npmjs.com/package/nuxt-schema-org" target="__blank"><img src="https://img.shields.io/npm/v/nuxt-schema-org?style=flat&colorA=002438&colorB=28CF8D" alt="NPM version"></a>
|
|
7
|
+
<a href="https://www.npmjs.com/package/nuxt-schema-org" target="__blank"><img alt="NPM Downloads" src="https://img.shields.io/npm/dm/nuxt-schema-org?flat&colorA=002438&colorB=28CF8D"></a>
|
|
8
|
+
<a href="https://github.com/harlan-zw/nuxt-schema-org" target="__blank"><img alt="GitHub stars" src="https://img.shields.io/github/stars/harlan-zw/nuxt-schema-org?flat&colorA=002438&colorB=28CF8D"></a>
|
|
9
|
+
</p>
|
|
4
10
|
|
|
5
|
-
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
The quickest and easiest way to build Schema.org graphs for Nuxt.
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p align="center">
|
|
17
|
+
<table>
|
|
18
|
+
<tbody>
|
|
19
|
+
<td align="center">
|
|
20
|
+
<img width="800" height="0" /><br>
|
|
21
|
+
<i>Status:</i> <a href="https://github.com/harlan-zw/nuxt-schema-org/releases/tag/v3.0.0">v3 Released 🎉</a></b> <br>
|
|
22
|
+
<sup> Please report any issues 🐛</sup><br>
|
|
23
|
+
<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>
|
|
24
|
+
<img width="800" height="0" />
|
|
25
|
+
</td>
|
|
26
|
+
</tbody>
|
|
27
|
+
</table>
|
|
28
|
+
</p>
|
|
29
|
+
|
|
30
|
+
## Features
|
|
31
|
+
|
|
32
|
+
- 😎 Simple API based on [Google](https://developers.google.com/search/docs/advanced/structured-data/search-gallery) and [Yoast](https://developer.yoast.com/features/schema/overview) best practices
|
|
33
|
+
- 🧙 30+ Nodes with automated relations, date, URL resolving and more for best practice Schema.org
|
|
34
|
+
- 💡 Simple global meta provides for minimal boilerplate
|
|
35
|
+
- 🌳 Minimal code, optimised for tree-shaking and SSR
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
1. Install `nuxt-schema-org` dependency to your project:
|
|
6
40
|
|
|
7
41
|
```bash
|
|
8
|
-
#
|
|
9
|
-
npm install -D nuxt-schema-org
|
|
10
|
-
# or Yarn
|
|
42
|
+
#
|
|
11
43
|
yarn add -D nuxt-schema-org
|
|
12
|
-
#
|
|
13
|
-
|
|
44
|
+
#
|
|
45
|
+
npm install -D nuxt-schema-org
|
|
46
|
+
#
|
|
47
|
+
pnpm i -D nuxt-schema-org
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
2. Add it to your `modules` section in your `nuxt.config`:
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
export default defineNuxtConfig({
|
|
55
|
+
modules: ['nuxt-schema-org']
|
|
56
|
+
})
|
|
14
57
|
```
|
|
15
58
|
|
|
16
|
-
|
|
59
|
+
# Documentation
|
|
60
|
+
|
|
61
|
+
[📖 Read the full documentation](https://nuxtseo.com/schema-org) for more information.
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
### Demos
|
|
65
|
+
|
|
66
|
+
- [Dynamic URLs - StackBlitz](https://stackblitz.com/edit/nuxt-starter-dyraxc?file=server%2Fapi%2F_sitemap-urls.ts)
|
|
67
|
+
- [i18n - StackBlitz](https://stackblitz.com/edit/nuxt-starter-jwuie4?file=app.vue)
|
|
68
|
+
|
|
69
|
+
## Sponsors
|
|
70
|
+
|
|
71
|
+
<p align="center">
|
|
72
|
+
<a href="https://raw.githubusercontent.com/harlan-zw/static/main/sponsors.svg">
|
|
73
|
+
<img src='https://raw.githubusercontent.com/harlan-zw/static/main/sponsors.svg'/>
|
|
74
|
+
</a>
|
|
75
|
+
</p>
|
|
17
76
|
|
|
18
|
-
Find documentation in the [Nuxt Setup](https://unhead-schema-org.harlanzw.com/guide/setup/nuxt.html) guide
|
|
19
77
|
|
|
20
78
|
## License
|
|
21
79
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { NuxtModule } from '@nuxt/schema';
|
|
2
|
+
import { MetaInput } from '@unhead/schema-org';
|
|
3
|
+
|
|
4
|
+
interface ModuleOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Whether the module should be loaded.
|
|
7
|
+
*
|
|
8
|
+
* @default true
|
|
9
|
+
*/
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the output should be minified.
|
|
13
|
+
*
|
|
14
|
+
* @default `process.env.NODE_ENV === 'production'`
|
|
15
|
+
*/
|
|
16
|
+
minify: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Whether the output should be reactive or just use the initial SSR output.
|
|
19
|
+
*
|
|
20
|
+
* @default `process.dev || !nuxt.options.ssr`
|
|
21
|
+
*/
|
|
22
|
+
reactive: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Enables debug logs.
|
|
25
|
+
*
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
debug: boolean;
|
|
29
|
+
}
|
|
30
|
+
interface ModuleHooks {
|
|
31
|
+
'schema-org:meta': (meta: MetaInput) => void | Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
interface ModulePublicRuntimeConfig {
|
|
34
|
+
['nuxt-schema-org']: MetaInput;
|
|
35
|
+
}
|
|
36
|
+
declare const _default: NuxtModule<ModuleOptions>;
|
|
37
|
+
|
|
38
|
+
export { type ModuleHooks, type ModuleOptions, type ModulePublicRuntimeConfig, _default as default };
|
package/dist/module.d.ts
CHANGED
|
@@ -1,15 +1,38 @@
|
|
|
1
|
-
import { MetaInput, UserConfig } from '@unhead/schema-org-vue';
|
|
2
1
|
import { NuxtModule } from '@nuxt/schema';
|
|
2
|
+
import { MetaInput } from '@unhead/schema-org';
|
|
3
3
|
|
|
4
|
-
interface ModuleOptions
|
|
4
|
+
interface ModuleOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Whether the module should be loaded.
|
|
7
|
+
*
|
|
8
|
+
* @default true
|
|
9
|
+
*/
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the output should be minified.
|
|
13
|
+
*
|
|
14
|
+
* @default `process.env.NODE_ENV === 'production'`
|
|
15
|
+
*/
|
|
16
|
+
minify: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Whether the output should be reactive or just use the initial SSR output.
|
|
19
|
+
*
|
|
20
|
+
* @default `process.dev || !nuxt.options.ssr`
|
|
21
|
+
*/
|
|
22
|
+
reactive: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Enables debug logs.
|
|
25
|
+
*
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
debug: boolean;
|
|
5
29
|
}
|
|
6
30
|
interface ModuleHooks {
|
|
31
|
+
'schema-org:meta': (meta: MetaInput) => void | Promise<void>;
|
|
7
32
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
'schema-org:meta': (meta: MetaInput) => void;
|
|
11
|
-
}
|
|
33
|
+
interface ModulePublicRuntimeConfig {
|
|
34
|
+
['nuxt-schema-org']: MetaInput;
|
|
12
35
|
}
|
|
13
36
|
declare const _default: NuxtModule<ModuleOptions>;
|
|
14
37
|
|
|
15
|
-
export { ModuleHooks, ModuleOptions, _default as default };
|
|
38
|
+
export { type ModuleHooks, type ModuleOptions, type ModulePublicRuntimeConfig, _default as default };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,44 +1,49 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, addPlugin,
|
|
2
|
-
import { schemaOrgComponents, schemaOrgAutoImports } from '@unhead/schema-org
|
|
1
|
+
import { defineNuxtModule, useLogger, createResolver, addPlugin, addComponent } from '@nuxt/kit';
|
|
2
|
+
import { schemaOrgComponents, schemaOrgAutoImports } from '@unhead/schema-org/vue';
|
|
3
|
+
import { installNuxtSiteConfig } from 'nuxt-site-config-kit';
|
|
3
4
|
|
|
4
5
|
const module = defineNuxtModule({
|
|
5
6
|
meta: {
|
|
6
7
|
name: "nuxt-schema-org",
|
|
7
8
|
configKey: "schemaOrg",
|
|
8
9
|
compatibility: {
|
|
9
|
-
nuxt: "^3.
|
|
10
|
+
nuxt: "^3.7.0",
|
|
10
11
|
bridge: false
|
|
11
12
|
}
|
|
12
13
|
},
|
|
13
14
|
defaults(nuxt) {
|
|
14
|
-
const trailingSlash = process.env.NUXT_PUBLIC_TRAILING_SLASH || nuxt.options.runtimeConfig.public.trailingSlash;
|
|
15
15
|
return {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
enabled: true,
|
|
17
|
+
debug: false,
|
|
18
|
+
reactive: nuxt.options.dev || !nuxt.options.ssr,
|
|
19
|
+
minify: process.env.NODE_ENV === "production"
|
|
18
20
|
};
|
|
19
21
|
},
|
|
20
22
|
async setup(config, nuxt) {
|
|
23
|
+
const logger = useLogger("nuxt-schema-org");
|
|
24
|
+
logger.level = config.debug || nuxt.options.debug ? 4 : 3;
|
|
25
|
+
if (config.enabled === false) {
|
|
26
|
+
logger.debug("The module is disabled, skipping setup.");
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
21
29
|
const { resolve } = createResolver(import.meta.url);
|
|
30
|
+
await installNuxtSiteConfig();
|
|
22
31
|
const moduleRuntimeDir = resolve("./runtime");
|
|
32
|
+
nuxt.options.runtimeConfig.public["nuxt-schema-org"] = config;
|
|
23
33
|
nuxt.options.build.transpile.push(...[
|
|
24
34
|
moduleRuntimeDir,
|
|
25
|
-
"@
|
|
26
|
-
"@unhead/schema-org-vue"
|
|
35
|
+
"@unhead/schema-org"
|
|
27
36
|
]);
|
|
28
37
|
addPlugin({
|
|
29
38
|
src: resolve(moduleRuntimeDir, "plugin"),
|
|
30
|
-
mode:
|
|
39
|
+
mode: config.reactive ? "all" : "server"
|
|
31
40
|
});
|
|
32
|
-
nuxt.options.alias["#nuxt-schema-org/config"] = addTemplate({
|
|
33
|
-
filename: "nuxt-schema-org-config.mjs",
|
|
34
|
-
getContents: () => `export default ${JSON.stringify(config)}`
|
|
35
|
-
}).dst;
|
|
36
41
|
for (const component of schemaOrgComponents) {
|
|
37
42
|
await addComponent({
|
|
38
43
|
name: component,
|
|
39
44
|
export: component,
|
|
40
45
|
chunkName: "nuxt-schema-org/components",
|
|
41
|
-
filePath: "@unhead/schema-org
|
|
46
|
+
filePath: "@unhead/schema-org/vue"
|
|
42
47
|
});
|
|
43
48
|
}
|
|
44
49
|
nuxt.hooks.hook("imports:sources", (autoImports) => {
|
package/dist/runtime/plugin.mjs
CHANGED
|
@@ -1,19 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { PluginSchemaOrg } from "@unhead/schema-org";
|
|
2
|
+
import { defineNuxtPlugin, injectHead, unref, useRouter, useRuntimeConfig, useSiteConfig } from "#imports";
|
|
3
|
+
export default defineNuxtPlugin({
|
|
4
|
+
name: "nuxt-schema-org:init",
|
|
5
|
+
enforce: "post",
|
|
6
|
+
setup(nuxtApp) {
|
|
7
|
+
const head = injectHead();
|
|
8
|
+
const config = useRuntimeConfig().public["nuxt-schema-org"];
|
|
9
|
+
const router = useRouter();
|
|
10
|
+
const currentRoute = router.currentRoute;
|
|
11
|
+
const siteConfig = useSiteConfig();
|
|
12
|
+
head.use(PluginSchemaOrg({
|
|
13
|
+
minify: config.minify,
|
|
14
|
+
resolveMeta: async () => {
|
|
15
|
+
const route = unref(currentRoute);
|
|
16
|
+
const meta = {
|
|
17
|
+
host: siteConfig.url,
|
|
18
|
+
trailingSlash: siteConfig.trailingSlash,
|
|
19
|
+
inLanguage: siteConfig.currentLocale || siteConfig.defaultLocale,
|
|
20
|
+
...siteConfig,
|
|
21
|
+
...route.meta,
|
|
22
|
+
path: route.path
|
|
23
|
+
};
|
|
24
|
+
await nuxtApp.hooks.callHook("schema-org:meta", meta);
|
|
25
|
+
return meta;
|
|
26
|
+
}
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
19
29
|
});
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
import { ModuleOptions, ModuleHooks, ModulePublicRuntimeConfig } from './module'
|
|
3
|
+
|
|
4
|
+
declare module '@nuxt/schema' {
|
|
5
|
+
interface NuxtConfig { ['schemaOrg']?: Partial<ModuleOptions> }
|
|
6
|
+
interface NuxtOptions { ['schemaOrg']?: ModuleOptions }
|
|
7
|
+
interface NuxtHooks extends ModuleHooks {}
|
|
8
|
+
interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare module 'nuxt/schema' {
|
|
12
|
+
interface NuxtConfig { ['schemaOrg']?: Partial<ModuleOptions> }
|
|
13
|
+
interface NuxtOptions { ['schemaOrg']?: ModuleOptions }
|
|
14
|
+
interface NuxtHooks extends ModuleHooks {}
|
|
15
|
+
interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
export { ModuleHooks, ModuleOptions, ModulePublicRuntimeConfig, default } from './module'
|
package/dist/types.d.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
|
|
2
|
-
import { ModuleOptions, ModuleHooks } from './module'
|
|
2
|
+
import { ModuleOptions, ModuleHooks, ModulePublicRuntimeConfig } from './module'
|
|
3
3
|
|
|
4
4
|
declare module '@nuxt/schema' {
|
|
5
5
|
interface NuxtConfig { ['schemaOrg']?: Partial<ModuleOptions> }
|
|
6
6
|
interface NuxtOptions { ['schemaOrg']?: ModuleOptions }
|
|
7
7
|
interface NuxtHooks extends ModuleHooks {}
|
|
8
|
+
interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
declare module 'nuxt/schema' {
|
|
11
12
|
interface NuxtConfig { ['schemaOrg']?: Partial<ModuleOptions> }
|
|
12
13
|
interface NuxtOptions { ['schemaOrg']?: ModuleOptions }
|
|
13
14
|
interface NuxtHooks extends ModuleHooks {}
|
|
15
|
+
interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
|
|
17
|
-
export { ModuleHooks, ModuleOptions, default } from './module'
|
|
19
|
+
export { ModuleHooks, ModuleOptions, ModulePublicRuntimeConfig, default } from './module'
|
package/package.json
CHANGED
|
@@ -1,52 +1,65 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-schema-org",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
5
|
-
"
|
|
4
|
+
"version": "3.0.0",
|
|
5
|
+
"packageManager": "pnpm@8.7.5",
|
|
6
|
+
"description": "Schema.org for Nuxt",
|
|
6
7
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
7
8
|
"license": "MIT",
|
|
8
9
|
"funding": "https://github.com/sponsors/harlan-zw",
|
|
9
|
-
"homepage": "https://
|
|
10
|
+
"homepage": "https://nuxtseo.com/schema-org",
|
|
10
11
|
"repository": {
|
|
11
12
|
"type": "git",
|
|
12
|
-
"url": "git+https://github.com/
|
|
13
|
-
"directory": "packages/nuxt"
|
|
13
|
+
"url": "git+https://github.com/harlan-zw/nuxt-schema-org.git"
|
|
14
14
|
},
|
|
15
15
|
"bugs": {
|
|
16
|
-
"url": "https://github.com/
|
|
16
|
+
"url": "https://github.com/harlan-zw/nuxt-schema-org/issues"
|
|
17
17
|
},
|
|
18
18
|
"keywords": [
|
|
19
19
|
"schema-org",
|
|
20
20
|
"nuxt",
|
|
21
|
-
"@
|
|
21
|
+
"@nuxt-schema-org",
|
|
22
22
|
"nuxt-module",
|
|
23
23
|
"nuxt3"
|
|
24
24
|
],
|
|
25
25
|
"exports": {
|
|
26
26
|
".": {
|
|
27
|
-
"
|
|
28
|
-
"import": "./dist/module.mjs"
|
|
27
|
+
"types": "./dist/types.d.ts",
|
|
28
|
+
"import": "./dist/module.mjs",
|
|
29
|
+
"require": "./dist/module.cjs"
|
|
29
30
|
}
|
|
30
31
|
},
|
|
31
|
-
"main": "dist/module.cjs",
|
|
32
|
-
"types": "dist/types.d.ts",
|
|
32
|
+
"main": "./dist/module.cjs",
|
|
33
|
+
"types": "./dist/types.d.ts",
|
|
33
34
|
"files": [
|
|
34
35
|
"dist"
|
|
35
36
|
],
|
|
36
37
|
"dependencies": {
|
|
37
|
-
"@nuxt/kit": "^3.
|
|
38
|
-
"@unhead/schema-org
|
|
39
|
-
"
|
|
38
|
+
"@nuxt/kit": "^3.7.3",
|
|
39
|
+
"@unhead/schema-org": "^1.7.3",
|
|
40
|
+
"nuxt-site-config": "^1.2.1",
|
|
41
|
+
"nuxt-site-config-kit": "^1.2.1",
|
|
42
|
+
"pathe": "^1.1.1"
|
|
40
43
|
},
|
|
41
44
|
"devDependencies": {
|
|
42
|
-
"@
|
|
43
|
-
"@nuxt/
|
|
44
|
-
"nuxt": "3.
|
|
45
|
+
"@antfu/eslint-config": "^0.42.0",
|
|
46
|
+
"@nuxt/module-builder": "^0.5.1",
|
|
47
|
+
"@nuxt/schema": "^3.7.3",
|
|
48
|
+
"@nuxt/test-utils": "^3.7.3",
|
|
49
|
+
"@nuxtjs/eslint-config-typescript": "^12.1.0",
|
|
50
|
+
"bumpp": "^9.2.0",
|
|
51
|
+
"eslint": "8.49.0",
|
|
52
|
+
"nuxt": "^3.7.3",
|
|
53
|
+
"nuxt-windicss": "^2.6.1",
|
|
54
|
+
"vitest": "0.34.4"
|
|
45
55
|
},
|
|
46
56
|
"scripts": {
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
57
|
+
"lint": "eslint . --fix",
|
|
58
|
+
"build": "pnpm run dev:prepare && nuxt-module-build",
|
|
59
|
+
"dev": "nuxi dev playground",
|
|
60
|
+
"dev:build": "nuxi build playground",
|
|
61
|
+
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
|
|
62
|
+
"release": "bumpp package.json --commit --push --tag",
|
|
63
|
+
"test": "vitest"
|
|
51
64
|
}
|
|
52
65
|
}
|