nuxt-schema-org 5.0.6 → 5.0.7

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.
Files changed (57) hide show
  1. package/package.json +31 -21
  2. package/dist/client/200.html +0 -14
  3. package/dist/client/404.html +0 -14
  4. package/dist/client/_nuxt/B73eqI6v.js +0 -1
  5. package/dist/client/_nuxt/BCcnOCi9.js +0 -174
  6. package/dist/client/_nuxt/BMMyXqK5.js +0 -1
  7. package/dist/client/_nuxt/CVO1_9PV.js +0 -1
  8. package/dist/client/_nuxt/Cp-IABpG.js +0 -1
  9. package/dist/client/_nuxt/D0r3Knsf.js +0 -1
  10. package/dist/client/_nuxt/builds/latest.json +0 -1
  11. package/dist/client/_nuxt/builds/meta/17f80431-2323-40d6-ab5c-1c16e0fa57ed.json +0 -1
  12. package/dist/client/_nuxt/entry.PRhstC-s.css +0 -1
  13. package/dist/client/_nuxt/error-404.B3xKW7zl.css +0 -1
  14. package/dist/client/_nuxt/error-500.BGJrBjm4.css +0 -1
  15. package/dist/client/_nuxt/tgLT0vNn.js +0 -1
  16. package/dist/client/index.html +0 -14
  17. package/dist/content.cjs +0 -28
  18. package/dist/content.d.cts +0 -19
  19. package/dist/content.d.mts +0 -19
  20. package/dist/content.d.ts +0 -19
  21. package/dist/content.mjs +0 -24
  22. package/dist/module.cjs +0 -205
  23. package/dist/module.d.cts +0 -51
  24. package/dist/module.d.mts +0 -49
  25. package/dist/module.d.ts +0 -51
  26. package/dist/module.json +0 -13
  27. package/dist/module.mjs +0 -202
  28. package/dist/runtime/app/composables/useSchemaOrg.d.ts +0 -4
  29. package/dist/runtime/app/composables/useSchemaOrg.js +0 -27
  30. package/dist/runtime/app/plugins/defaults.d.ts +0 -2
  31. package/dist/runtime/app/plugins/defaults.js +0 -28
  32. package/dist/runtime/app/plugins/i18n/defaults.d.ts +0 -2
  33. package/dist/runtime/app/plugins/i18n/defaults.js +0 -77
  34. package/dist/runtime/app/plugins/i18n/init.d.ts +0 -2
  35. package/dist/runtime/app/plugins/i18n/init.js +0 -11
  36. package/dist/runtime/app/plugins/i18n/tsconfig.json +0 -3
  37. package/dist/runtime/app/plugins/init.d.ts +0 -2
  38. package/dist/runtime/app/plugins/init.js +0 -8
  39. package/dist/runtime/app/utils/config.d.ts +0 -2
  40. package/dist/runtime/app/utils/config.js +0 -8
  41. package/dist/runtime/app/utils/shared.d.ts +0 -3
  42. package/dist/runtime/app/utils/shared.js +0 -99
  43. package/dist/runtime/server/plugins/nuxt-content-v2.d.ts +0 -2
  44. package/dist/runtime/server/plugins/nuxt-content-v2.js +0 -37
  45. package/dist/runtime/server/routes/__schema-org__/debug.d.ts +0 -5
  46. package/dist/runtime/server/routes/__schema-org__/debug.js +0 -10
  47. package/dist/runtime/server/tsconfig.json +0 -3
  48. package/dist/runtime/server/utils/config.d.ts +0 -3
  49. package/dist/runtime/server/utils/config.js +0 -8
  50. package/dist/runtime/types.d.ts +0 -9
  51. package/dist/runtime/types.js +0 -0
  52. package/dist/schema.cjs +0 -16
  53. package/dist/schema.d.cts +0 -1
  54. package/dist/schema.d.mts +0 -1
  55. package/dist/schema.d.ts +0 -1
  56. package/dist/schema.mjs +0 -1
  57. package/dist/types.d.mts +0 -7
package/dist/module.d.ts DELETED
@@ -1,51 +0,0 @@
1
- import { NuxtModule } from '@nuxt/schema';
2
- import { OrganizationSimple, PersonSimple, LocalBusinessSimple } from '@unhead/schema-org';
3
- import { Script } from '@unhead/vue/types';
4
-
5
- interface ModuleOptions {
6
- /**
7
- * Whether a default WebPage, WebSite and Identity node be created.
8
- */
9
- defaults?: boolean;
10
- /**
11
- * The identity of the site.
12
- */
13
- identity?: 'Person' | 'Organization' | 'LocalBusiness' | OrganizationSimple | PersonSimple | LocalBusinessSimple;
14
- /**
15
- * Whether the module should be loaded.
16
- *
17
- * @default true
18
- */
19
- enabled: boolean;
20
- /**
21
- * Whether the output should be minified.
22
- *
23
- * @default `process.env.NODE_ENV === 'production'`
24
- */
25
- minify: boolean;
26
- /**
27
- * Whether the output should be reactive or just use the initial SSR output.
28
- *
29
- * @default `process.dev || !nuxt.options.ssr`
30
- */
31
- reactive: boolean;
32
- /**
33
- * Attributes to apply to the script tag containing the LD+JSON Schema.org snippet.
34
- *
35
- * By default, will apply an `id` of `schema-org-graph`. Set to `false` to apply no attributes.
36
- */
37
- scriptAttributes?: Script | false;
38
- /**
39
- * Enables debug logs.
40
- *
41
- * @default false
42
- */
43
- debug: boolean;
44
- }
45
- interface ModuleHooks {
46
- }
47
- declare const _default: NuxtModule<ModuleOptions>;
48
-
49
- // @ts-ignore
50
- export = _default;
51
- export type { ModuleHooks, ModuleOptions };
package/dist/module.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "name": "nuxt-schema-org",
3
- "configKey": "schemaOrg",
4
- "compatibility": {
5
- "nuxt": ">=3.16.0",
6
- "bridge": false
7
- },
8
- "version": "5.0.5",
9
- "builder": {
10
- "@nuxt/module-builder": "1.0.1",
11
- "unbuild": "3.5.0"
12
- }
13
- }
package/dist/module.mjs DELETED
@@ -1,202 +0,0 @@
1
- import { useNuxt, createResolver, addTemplate, defineNuxtModule, useLogger, hasNuxtModule, addPlugin, hasNuxtModuleCompatibility, addServerPlugin, addComponent, addImports, addServerHandler } from '@nuxt/kit';
2
- import { defineWebPage } from '@unhead/schema-org';
3
- import { schemaOrgAutoImports, schemaOrgComponents } from '@unhead/schema-org/vue';
4
- import { defu } from 'defu';
5
- import { installNuxtSiteConfig } from 'nuxt-site-config/kit';
6
- import { readPackageJSON } from 'pkg-types';
7
- import { existsSync } from 'node:fs';
8
- import { relative } from 'pathe';
9
-
10
- const DEVTOOLS_UI_ROUTE = "/__nuxt-schema-org";
11
- const DEVTOOLS_UI_LOCAL_PORT = 3030;
12
- function setupDevToolsUI(options, resolve, nuxt = useNuxt()) {
13
- const clientPath = resolve("./client");
14
- const isProductionBuild = existsSync(clientPath);
15
- if (isProductionBuild) {
16
- nuxt.hook("vite:serverCreated", async (server) => {
17
- const sirv = await import('sirv').then((r) => r.default || r);
18
- server.middlewares.use(
19
- DEVTOOLS_UI_ROUTE,
20
- sirv(clientPath, { dev: true, single: true })
21
- );
22
- });
23
- } else {
24
- nuxt.hook("vite:extendConfig", (config) => {
25
- config.server = config.server || {};
26
- config.server.proxy = config.server.proxy || {};
27
- config.server.proxy[DEVTOOLS_UI_ROUTE] = {
28
- target: `http://localhost:${DEVTOOLS_UI_LOCAL_PORT}${DEVTOOLS_UI_ROUTE}`,
29
- changeOrigin: true,
30
- followRedirects: true,
31
- rewrite: (path) => path.replace(DEVTOOLS_UI_ROUTE, "")
32
- };
33
- });
34
- }
35
- nuxt.hook("devtools:customTabs", (tabs) => {
36
- tabs.push({
37
- // unique identifier
38
- name: "nuxt-schema-org",
39
- // title to display in the tab
40
- title: "Schema.org",
41
- // any icon from Iconify, or a URL to an image
42
- icon: "carbon:chart-relationship",
43
- // iframe view
44
- view: {
45
- type: "iframe",
46
- src: DEVTOOLS_UI_ROUTE
47
- }
48
- });
49
- });
50
- }
51
-
52
- function extendTypes(module, template) {
53
- const nuxt = useNuxt();
54
- const { resolve } = createResolver(import.meta.url);
55
- addTemplate({
56
- filename: `module/${module}.d.ts`,
57
- getContents: async () => {
58
- const typesPath = relative(resolve(nuxt.options.rootDir, nuxt.options.buildDir, "module"), resolve("runtime/types"));
59
- const s = await template({ typesPath });
60
- return `// Generated by ${module}
61
- ${s}
62
- export {}
63
- `;
64
- }
65
- });
66
- nuxt.hooks.hook("prepare:types", ({ references }) => {
67
- references.push({ path: resolve(nuxt.options.buildDir, `module/${module}.d.ts`) });
68
- });
69
- }
70
-
71
- const module = defineNuxtModule({
72
- meta: {
73
- name: "nuxt-schema-org",
74
- configKey: "schemaOrg",
75
- compatibility: {
76
- nuxt: ">=3.16.0",
77
- bridge: false
78
- }
79
- },
80
- defaults(nuxt) {
81
- return {
82
- enabled: true,
83
- defaults: true,
84
- reactive: nuxt.options.dev || !nuxt.options.ssr,
85
- minify: !nuxt.options.dev,
86
- scriptAttributes: {
87
- "data-nuxt-schema-org": true
88
- }
89
- };
90
- },
91
- async setup(config, nuxt) {
92
- const { resolve } = createResolver(import.meta.url);
93
- const { name, version } = await readPackageJSON(resolve("../package.json"));
94
- const logger = useLogger(name);
95
- logger.level = config.debug ? 4 : 3;
96
- if (config.enabled === false) {
97
- logger.debug("The module is disabled, skipping setup.");
98
- return;
99
- }
100
- if (!nuxt.options.ssr && nuxt.options.dev)
101
- logger.warn("You are using Schema.org with SSR disabled. This is not recommended, Google may not detect your Schema.org, and it adds extra page weight");
102
- await installNuxtSiteConfig();
103
- const runtimeConfig = {
104
- reactive: config.reactive,
105
- minify: config.minify,
106
- scriptAttributes: config.scriptAttributes,
107
- identity: config.identity,
108
- version
109
- };
110
- if (config.reactive)
111
- nuxt.options.runtimeConfig.public["nuxt-schema-org"] = runtimeConfig;
112
- nuxt.options.runtimeConfig["nuxt-schema-org"] = runtimeConfig;
113
- const pluginPath = hasNuxtModule("@nuxtjs/i18n") && nuxt.options.i18n?.locales ? "./runtime/app/plugins/i18n" : "./runtime/app/plugins";
114
- addPlugin({
115
- src: resolve(pluginPath, "init"),
116
- mode: config.reactive ? "all" : "server"
117
- });
118
- if (config.defaults) {
119
- addPlugin({
120
- src: resolve(pluginPath, "defaults"),
121
- mode: config.reactive ? "all" : "server"
122
- });
123
- }
124
- nuxt.options.alias["#schema-org"] = resolve("./runtime");
125
- const usingNuxtContent = hasNuxtModule("@nuxt/content");
126
- const isNuxtContentV3 = usingNuxtContent && await hasNuxtModuleCompatibility("@nuxt/content", "^3");
127
- const isNuxtContentV2 = usingNuxtContent && await hasNuxtModuleCompatibility("@nuxt/content", "^2");
128
- if (isNuxtContentV3) {
129
- nuxt.hooks.hook("content:file:afterParse", (ctx) => {
130
- if (typeof ctx.content.schemaOrg === "undefined") {
131
- return;
132
- }
133
- const content = ctx.content;
134
- const nodes = Array.isArray(content.schemaOrg) ? content.schemaOrg : [defineWebPage(content.schemaOrg)];
135
- const replaceType = (node) => {
136
- if (node.type) {
137
- node["@type"] = node.type;
138
- delete node.type;
139
- }
140
- Object.entries(node).forEach(([, value]) => {
141
- if (typeof value === "object") {
142
- replaceType(value);
143
- }
144
- });
145
- return node;
146
- };
147
- const script = {
148
- type: "application/ld+json",
149
- key: "schema-org-graph",
150
- ...config.scriptAttributes,
151
- nodes: nodes.map(replaceType)
152
- };
153
- content.head = defu({ script: [script] }, content.head);
154
- ctx.content = content;
155
- });
156
- } else if (isNuxtContentV2) {
157
- addServerPlugin(resolve("./runtime/server/plugins/nuxt-content-v2"));
158
- }
159
- if (!config.reactive)
160
- nuxt.options.optimization.treeShake.composables.client["nuxt-schema-org"] = schemaOrgAutoImports[0].imports;
161
- for (const component of schemaOrgComponents) {
162
- await addComponent({
163
- name: component,
164
- export: component,
165
- chunkName: "nuxt-schema-org/components",
166
- filePath: "@unhead/schema-org/vue"
167
- });
168
- }
169
- addImports({
170
- from: resolve("./runtime/app/composables/useSchemaOrg"),
171
- name: "useSchemaOrg"
172
- });
173
- nuxt.hooks.hook("imports:sources", (autoImports) => {
174
- schemaOrgAutoImports[0].imports = schemaOrgAutoImports[0].imports.filter((i) => i !== "useSchemaOrg");
175
- autoImports.unshift(...schemaOrgAutoImports);
176
- });
177
- extendTypes("nuxt-schema-org", ({ typesPath }) => {
178
- return `
179
- declare module '@nuxt/schema' {
180
- export interface RuntimeNuxtHooks {
181
- 'schema-org:meta': (meta: import('${typesPath}').MetaInput) => void | Promise<void>
182
- }
183
- }
184
- declare module '#app' {
185
- export interface RuntimeNuxtHooks {
186
- 'schema-org:meta': (meta: import('${typesPath}').MetaInput) => void | Promise<void>
187
- }
188
- }
189
- `;
190
- });
191
- if (config.debug || nuxt.options.dev) {
192
- addServerHandler({
193
- route: "/__schema-org__/debug.json",
194
- handler: resolve("./runtime/server/routes/__schema-org__/debug")
195
- });
196
- }
197
- if (nuxt.options.dev)
198
- setupDevToolsUI(config, resolve);
199
- }
200
- });
201
-
202
- export { module as default };
@@ -1,4 +0,0 @@
1
- import type { useSchemaOrg as _useSchemaOrg } from '@unhead/schema-org/vue';
2
- type Input = Parameters<typeof _useSchemaOrg>[0];
3
- export declare function useSchemaOrg<T extends Input>(input: T): void | import("@unhead/vue").ActiveHeadEntry<import("@unhead/vue").UseHeadInput<Deprecated>>;
4
- export {};
@@ -1,27 +0,0 @@
1
- import { useHead } from "#imports";
2
- import { useSchemaOrgConfig } from "../utils/config.js";
3
- export function useSchemaOrg(input) {
4
- const config = useSchemaOrgConfig();
5
- const script = {
6
- type: "application/ld+json",
7
- key: "schema-org-graph",
8
- // @ts-expect-error untyped
9
- nodes: input,
10
- tagPriority: "high",
11
- ...config.scriptAttributes
12
- };
13
- if (import.meta.dev) {
14
- return useHead({
15
- script: [script]
16
- });
17
- }
18
- if (import.meta.server) {
19
- return useHead({
20
- script: [script]
21
- });
22
- } else if (config?.reactive) {
23
- return useHead({
24
- script: [script]
25
- });
26
- }
27
- }
@@ -1,2 +0,0 @@
1
- declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
2
- export default _default;
@@ -1,28 +0,0 @@
1
- import { useSiteConfig } from "#site-config/app/composables/useSiteConfig";
2
- import { defineWebPage, defineWebSite } from "@unhead/schema-org/vue";
3
- import { defineNuxtPlugin, useError } from "nuxt/app";
4
- import { toValue } from "vue";
5
- import { useSchemaOrg } from "../composables/useSchemaOrg.js";
6
- import { maybeAddIdentitySchemaOrg } from "../utils/shared.js";
7
- export default defineNuxtPlugin({
8
- name: "nuxt-schema-org:defaults",
9
- dependsOn: [
10
- "nuxt-schema-org:init"
11
- ],
12
- setup() {
13
- const error = useError();
14
- if (error.value?.error) {
15
- return;
16
- }
17
- const siteConfig = useSiteConfig();
18
- useSchemaOrg([
19
- defineWebSite({
20
- name: () => toValue(siteConfig.name) || "",
21
- inLanguage: () => toValue(siteConfig.currentLocale) || "",
22
- description: () => toValue(siteConfig.description) || ""
23
- }),
24
- defineWebPage()
25
- ]);
26
- maybeAddIdentitySchemaOrg();
27
- }
28
- });
@@ -1,2 +0,0 @@
1
- declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
2
- export default _default;
@@ -1,77 +0,0 @@
1
- import { useLocalePath } from "#i18n";
2
- import { useSiteConfig } from "#site-config/app/composables/useSiteConfig";
3
- import { createSitePathResolver } from "#site-config/app/composables/utils";
4
- import { defineWebPage, defineWebSite } from "@unhead/schema-org/vue";
5
- import { resolveSitePath } from "nuxt-site-config/urls";
6
- import { defineNuxtPlugin, useError, useRuntimeConfig } from "nuxt/app";
7
- import { hasProtocol, withHttps } from "ufo";
8
- import { toValue } from "vue";
9
- import { useSchemaOrg } from "../../composables/useSchemaOrg.js";
10
- import { maybeAddIdentitySchemaOrg } from "../../utils/shared.js";
11
- export default defineNuxtPlugin({
12
- name: "nuxt-schema-org:defaults",
13
- dependsOn: [
14
- "nuxt-schema-org:init"
15
- ],
16
- setup(nuxtApp) {
17
- const error = useError();
18
- if (error.value?.error) {
19
- return;
20
- }
21
- const siteConfig = useSiteConfig();
22
- const pathResolver = createSitePathResolver({
23
- canonical: true,
24
- absolute: true
25
- });
26
- if (!nuxtApp.$i18n)
27
- return;
28
- const localePath = useLocalePath();
29
- const locales = nuxtApp.$i18n?.locales.value || [];
30
- const siteUrl = () => pathResolver(localePath("index")).value;
31
- const websiteId = () => `${siteUrl()}#website`;
32
- const website = defineWebSite({
33
- "@id": websiteId,
34
- "url": siteUrl,
35
- "name": () => toValue(siteConfig.name) || "",
36
- // @ts-expect-error untyped
37
- "inLanguage": () => toValue(nuxtApp.$i18n.localeProperties.value.language) || "",
38
- "description": () => toValue(siteConfig.description) || ""
39
- });
40
- const nuxtBase = useRuntimeConfig().app.baseURL || "/";
41
- const resolveIdForLocale = (locale) => {
42
- if (locale.domain) {
43
- return resolveSitePath(localePath("index", locale.code), {
44
- absolute: true,
45
- siteUrl: hasProtocol(locale.domain, { acceptRelative: false }) ? locale.domain : withHttps(locale.domain),
46
- trailingSlash: siteConfig.trailingSlash,
47
- base: nuxtBase
48
- });
49
- }
50
- return pathResolver(localePath("index", locale.code)).value;
51
- };
52
- if (siteConfig.defaultLocale) {
53
- if (siteConfig.currentLocale && siteConfig.currentLocale !== siteConfig.defaultLocale) {
54
- website.translationOfWork = {
55
- "@type": "WebSite",
56
- "@id": () => `${resolveIdForLocale({ code: toValue(siteConfig.defaultLocale) })}#website`
57
- };
58
- } else {
59
- website.workTranslation = locales.filter((locale) => locale.code !== siteConfig.defaultLocale).map((locale) => {
60
- return {
61
- "@type": "WebSite",
62
- "@id": () => `${resolveIdForLocale(locale)}#website`
63
- };
64
- });
65
- }
66
- }
67
- useSchemaOrg([
68
- website,
69
- defineWebPage({
70
- isPartOf: {
71
- "@id": websiteId()
72
- }
73
- })
74
- ]);
75
- maybeAddIdentitySchemaOrg();
76
- }
77
- });
@@ -1,2 +0,0 @@
1
- declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
2
- export default _default;
@@ -1,11 +0,0 @@
1
- import { defineNuxtPlugin } from "nuxt/app";
2
- import { initPlugin } from "../../utils/shared.js";
3
- export default defineNuxtPlugin({
4
- name: "nuxt-schema-org:init",
5
- order: 999,
6
- // @ts-expect-error untyped
7
- dependsOn: ["i18n:plugin"],
8
- setup(nuxtApp) {
9
- initPlugin(nuxtApp);
10
- }
11
- });
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "../../../../../test/fixtures/i18n/.nuxt/tsconfig.json"
3
- }
@@ -1,2 +0,0 @@
1
- declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
2
- export default _default;
@@ -1,8 +0,0 @@
1
- import { defineNuxtPlugin } from "nuxt/app";
2
- import { initPlugin } from "../utils/shared.js";
3
- export default defineNuxtPlugin({
4
- name: "nuxt-schema-org:init",
5
- setup(nuxtApp) {
6
- initPlugin(nuxtApp);
7
- }
8
- });
@@ -1,2 +0,0 @@
1
- import type { ModuleRuntimeConfig } from '#schema-org/types';
2
- export declare function useSchemaOrgConfig(): ModuleRuntimeConfig;
@@ -1,8 +0,0 @@
1
- import { defu } from "defu";
2
- import { useRuntimeConfig } from "nuxt/app";
3
- export function useSchemaOrgConfig() {
4
- const runtimeConfig = useRuntimeConfig();
5
- return defu(import.meta.client ? runtimeConfig.public["nuxt-schema-org"] : runtimeConfig["nuxt-schema-org"], {
6
- scriptAttributes: {}
7
- });
8
- }
@@ -1,3 +0,0 @@
1
- import type { NuxtApp } from 'nuxt/app';
2
- export declare function initPlugin(nuxtApp: NuxtApp): void;
3
- export declare function maybeAddIdentitySchemaOrg(): void;
@@ -1,99 +0,0 @@
1
- import { injectHead, useHead } from "#imports";
2
- import {
3
- useSiteConfig
4
- } from "#site-config/app/composables/useSiteConfig";
5
- import { createSitePathResolver } from "#site-config/app/composables/utils";
6
- import { SchemaOrgUnheadPlugin } from "@unhead/schema-org/vue";
7
- import { useRoute } from "nuxt/app";
8
- import { camelCase } from "scule";
9
- import { withTrailingSlash } from "ufo";
10
- import { computed, toValue, watch } from "vue";
11
- import { useSchemaOrg } from "../composables/useSchemaOrg.js";
12
- import { useSchemaOrgConfig } from "./config.js";
13
- export function initPlugin(nuxtApp) {
14
- const head = injectHead();
15
- const config = useSchemaOrgConfig();
16
- const route = useRoute();
17
- const siteConfig = useSiteConfig();
18
- const resolvePath = createSitePathResolver({
19
- absolute: false,
20
- withBase: true
21
- });
22
- const resolveUrl = createSitePathResolver({
23
- canonical: true,
24
- absolute: true,
25
- withBase: true
26
- });
27
- const schemaOrg = computed(() => {
28
- const siteConfigResolved = {};
29
- for (const key in siteConfig) {
30
- if (key.startsWith("_")) {
31
- continue;
32
- }
33
- siteConfigResolved[key] = toValue(siteConfig[key]);
34
- if (typeof siteConfigResolved[key] === "object") {
35
- for (const k in siteConfigResolved[key]) {
36
- siteConfigResolved[key][k] = toValue(siteConfigResolved[key][k]);
37
- }
38
- }
39
- }
40
- return {
41
- ...route.meta?.schemaOrg || {},
42
- ...siteConfigResolved,
43
- url: toValue(resolveUrl(route.path)),
44
- host: withTrailingSlash(siteConfigResolved.url),
45
- inLanguage: toValue(siteConfigResolved.currentLocale) || toValue(siteConfigResolved.defaultLocale),
46
- path: toValue(resolvePath(route.path))
47
- };
48
- });
49
- const templateParamEntry = useHead({
50
- templateParams: { schemaOrg: schemaOrg.value }
51
- });
52
- watch(() => siteConfig, () => {
53
- templateParamEntry.patch({
54
- templateParams: { schemaOrg: schemaOrg.value }
55
- });
56
- }, { deep: true });
57
- head.use(
58
- SchemaOrgUnheadPlugin({}, async () => {
59
- const meta = {};
60
- await nuxtApp.hooks.callHook("schema-org:meta", meta);
61
- return meta;
62
- }, {
63
- minify: config.minify,
64
- trailingSlash: siteConfig.trailingSlash
65
- })
66
- );
67
- }
68
- export function maybeAddIdentitySchemaOrg() {
69
- const config = useSchemaOrgConfig();
70
- const siteConfig = useSiteConfig({
71
- resolveRefs: true
72
- });
73
- if (config.identity || siteConfig.identity) {
74
- const identity = config.identity || siteConfig.identity;
75
- let identityPayload = {
76
- name: () => toValue(siteConfig.name),
77
- url: () => toValue(siteConfig.url)
78
- };
79
- let identityType;
80
- if (typeof identity !== "string") {
81
- identityPayload = {
82
- ...identityPayload,
83
- ...identity
84
- };
85
- identityType = identity.type;
86
- delete identityPayload.type;
87
- } else {
88
- identityType = identity;
89
- }
90
- if (siteConfig.twitter) {
91
- const id = siteConfig.twitter.startsWith("@") ? siteConfig.twitter.slice(1) : siteConfig.twitter;
92
- identityPayload.sameAs = [
93
- `https://twitter.com/${id}`
94
- ];
95
- }
96
- identityPayload._resolver = identityPayload._resolver || camelCase(identityType);
97
- useSchemaOrg([identityPayload]);
98
- }
99
- }
@@ -1,2 +0,0 @@
1
- declare const _default: import("nitropack/types").NitroAppPlugin;
2
- export default _default;
@@ -1,37 +0,0 @@
1
- import { defineWebPage } from "@unhead/schema-org/vue";
2
- import { defu } from "defu";
3
- import { defineNitroPlugin } from "nitropack/runtime";
4
- import { useSchemaOrgConfig } from "../utils/config.js";
5
- export default defineNitroPlugin((nitroApp) => {
6
- const config = useSchemaOrgConfig();
7
- nitroApp.hooks.hook("content:file:afterParse", async (content) => {
8
- if (content._draft || content._extension !== "md" || content._partial || content.indexable === false || content.index === false)
9
- return;
10
- if (!content.schemaOrg) {
11
- return;
12
- }
13
- const nodes = Array.isArray(content.schemaOrg) ? content.schemaOrg : [defineWebPage(content.schemaOrg)];
14
- const replaceType = (node) => {
15
- if (node.type) {
16
- node["@type"] = node.type;
17
- delete node.type;
18
- }
19
- Object.entries(node).forEach(([, value]) => {
20
- if (typeof value === "object") {
21
- replaceType(value);
22
- }
23
- });
24
- return node;
25
- };
26
- const script = {
27
- type: "application/ld+json",
28
- key: "schema-org-graph",
29
- nodes: nodes.map(replaceType),
30
- ...config.scriptAttributes
31
- };
32
- content.head = defu({
33
- script: [script]
34
- }, content.head);
35
- return content;
36
- });
37
- });
@@ -1,5 +0,0 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<{
2
- nitroOrigin: string;
3
- runtimeConfig: import("../../../types.js").ModuleRuntimeConfig;
4
- }>>;
5
- export default _default;
@@ -1,10 +0,0 @@
1
- import { useNitroOrigin } from "#site-config/server/composables/useNitroOrigin";
2
- import { defineEventHandler } from "h3";
3
- import { useSchemaOrgConfig } from "../../utils/config.js";
4
- export default defineEventHandler(async (e) => {
5
- const nitroOrigin = useNitroOrigin(e);
6
- return {
7
- nitroOrigin,
8
- runtimeConfig: useSchemaOrgConfig(e)
9
- };
10
- });
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "../../../.nuxt/tsconfig.server.json"
3
- }
@@ -1,3 +0,0 @@
1
- import type { ModuleRuntimeConfig } from '#schema-org/types';
2
- import type { H3Event } from 'h3';
3
- export declare function useSchemaOrgConfig(e?: H3Event): ModuleRuntimeConfig;
@@ -1,8 +0,0 @@
1
- import { defu } from "defu";
2
- import { useRuntimeConfig } from "nitropack/runtime";
3
- export function useSchemaOrgConfig(e) {
4
- const runtimeConfig = useRuntimeConfig(e);
5
- return defu(import.meta.client ? runtimeConfig.public["nuxt-schema-org"] : runtimeConfig["nuxt-schema-org"], {
6
- scriptAttributes: {}
7
- });
8
- }
@@ -1,9 +0,0 @@
1
- import type { ModuleOptions } from '../module.js';
2
- export type ModuleRuntimeConfig = Pick<ModuleOptions, 'scriptAttributes' | 'reactive' | 'minify' | 'identity'> & {
3
- version: string;
4
- };
5
- export interface UnheadAugmentation<T> {
6
- script: {
7
- nodes: T;
8
- };
9
- }
File without changes