nuxt-schema-org 0.5.2 → 0.6.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/dist/module.d.ts +2 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +2 -1
- package/dist/runtime/composables.d.ts +2 -0
- package/dist/runtime/composables.mjs +8 -0
- package/dist/runtime/plugin.mjs +26 -9
- package/package.json +3 -2
package/dist/module.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
1
|
import { SchemaOrgOptions } from '@vueuse/schema-org';
|
|
2
|
+
import { NuxtModule } from '@nuxt/schema';
|
|
3
3
|
|
|
4
4
|
interface ModuleOptions extends SchemaOrgOptions {
|
|
5
5
|
/**
|
|
@@ -15,6 +15,6 @@ interface ModuleOptions extends SchemaOrgOptions {
|
|
|
15
15
|
}
|
|
16
16
|
interface ModuleHooks {
|
|
17
17
|
}
|
|
18
|
-
declare const _default:
|
|
18
|
+
declare const _default: NuxtModule<ModuleOptions>;
|
|
19
19
|
|
|
20
20
|
export { ModuleHooks, ModuleOptions, _default as default };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -15,6 +15,7 @@ const module = defineNuxtModule({
|
|
|
15
15
|
async setup(config, nuxt) {
|
|
16
16
|
const { resolve } = createResolver(import.meta.url);
|
|
17
17
|
addPlugin(resolve("./runtime/plugin"));
|
|
18
|
+
nuxt.options.build.transpile.push("@vueuse/schema-org");
|
|
18
19
|
addTemplate({
|
|
19
20
|
filename: "schemaOrg.config.mjs",
|
|
20
21
|
getContents: () => `export default ${JSON.stringify({ config })}`
|
|
@@ -22,7 +23,7 @@ const module = defineNuxtModule({
|
|
|
22
23
|
if (config.autoImportComposables) {
|
|
23
24
|
nuxt.hooks.hookOnce("autoImports:sources", (autoImports) => {
|
|
24
25
|
autoImports.unshift({
|
|
25
|
-
from: "
|
|
26
|
+
from: resolve("./runtime/composables"),
|
|
26
27
|
imports: schemaOrgAutoImports["@vueuse/schema-org"]
|
|
27
28
|
});
|
|
28
29
|
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { isFunction } from "@vue/shared";
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { useNuxtApp } from "#app";
|
|
4
|
+
export * from "@vueuse/schema-org";
|
|
5
|
+
export function useSchemaOrg(schema) {
|
|
6
|
+
const resolvedSchema = isFunction(schema) ? computed(schema) : schema;
|
|
7
|
+
useNuxtApp()._useSchemaOrg(resolvedSchema);
|
|
8
|
+
}
|
package/dist/runtime/plugin.mjs
CHANGED
|
@@ -1,18 +1,35 @@
|
|
|
1
|
-
import { createSchemaOrg } from "@vueuse/schema-org";
|
|
1
|
+
import { createSchemaOrg, useVueUseHead } from "@vueuse/schema-org";
|
|
2
2
|
import { defineNuxtPlugin } from "#app";
|
|
3
|
-
import { useRoute, watchEffect } from "#imports";
|
|
3
|
+
import { getCurrentInstance, onBeforeUnmount, useRoute, watch, watchEffect } from "#imports";
|
|
4
4
|
import meta from "#build/schemaOrg.config.mjs";
|
|
5
5
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
6
6
|
const head = nuxtApp.vueApp._context.provides.usehead;
|
|
7
7
|
const schemaOrg = createSchemaOrg({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
provider: {
|
|
9
|
+
useRoute,
|
|
10
|
+
setupDOM: useVueUseHead(head),
|
|
11
|
+
name: "nuxt"
|
|
12
|
+
},
|
|
11
13
|
...meta.config
|
|
12
14
|
});
|
|
13
15
|
nuxtApp.vueApp.use(schemaOrg);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
let _uid = 0;
|
|
17
|
+
nuxtApp._useSchemaOrg = (input) => {
|
|
18
|
+
const vm = getCurrentInstance();
|
|
19
|
+
const ctx = schemaOrg.setupRouteContext(vm?.uid || _uid++);
|
|
20
|
+
schemaOrg.addNodesAndResolveRelations(ctx, input);
|
|
21
|
+
watch(useRoute(), () => {
|
|
22
|
+
schemaOrg.removeContext(ctx);
|
|
23
|
+
schemaOrg.addNodesAndResolveRelations(ctx, input);
|
|
24
|
+
schemaOrg.generateSchema();
|
|
25
|
+
});
|
|
26
|
+
watchEffect(() => {
|
|
27
|
+
schemaOrg.generateSchema();
|
|
28
|
+
});
|
|
29
|
+
onBeforeUnmount(() => {
|
|
30
|
+
schemaOrg.removeContext(ctx);
|
|
31
|
+
schemaOrg.generateSchema();
|
|
32
|
+
});
|
|
33
|
+
schemaOrg.setupDOM();
|
|
34
|
+
};
|
|
18
35
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-schema-org",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Nuxt module for @vueuse/schema-org",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"schema-org",
|
|
@@ -36,10 +36,11 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@nuxt/kit": "3.0.0-rc.2",
|
|
39
|
-
"@vueuse/schema-org": "0.
|
|
39
|
+
"@vueuse/schema-org": "0.6.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@nuxt/module-builder": "latest",
|
|
43
|
+
"@nuxt/schema": "^3.0.0-rc.2",
|
|
43
44
|
"nuxt": "^3.0.0-rc.2"
|
|
44
45
|
},
|
|
45
46
|
"scripts": {
|