nuxt-schema-org 1.1.0-beta.5 → 2.0.0-beta.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 CHANGED
@@ -1,12 +1,11 @@
1
- import { UserConfig } from '@vueuse/schema-org';
1
+ import { MetaInput, UserConfig } from '@unhead/schema-org-vue';
2
2
  import { NuxtModule } from '@nuxt/schema';
3
- import { MetaInput } from 'schema-org-graph-js';
4
3
 
5
4
  interface ModuleOptions extends UserConfig {
6
5
  }
7
6
  interface ModuleHooks {
8
7
  }
9
- declare module 'nuxt' {
8
+ declare module '@nuxt/schema' {
10
9
  interface RuntimeNuxtHooks {
11
10
  'schema-org:meta': (meta: MetaInput) => void;
12
11
  }
package/dist/module.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "configKey": "schemaOrg",
3
3
  "compatibility": {
4
- "nuxt": ">=3.0.0-rc.9",
4
+ "nuxt": "3.0.0",
5
5
  "bridge": false
6
6
  },
7
7
  "name": "nuxt-schema-org",
8
- "version": "1.1.0-beta.5"
8
+ "version": "2.0.0-beta.0"
9
9
  }
package/dist/module.mjs CHANGED
@@ -1,73 +1,41 @@
1
- import { defineNuxtModule, createResolver, addPlugin, addTemplate, addComponent, importModule, extendWebpackConfig } from '@nuxt/kit';
2
- import { resolveUserConfig, AliasRuntime, schemaOrgComponents, schemaOrgAutoImports } from '@vueuse/schema-org';
3
- import { dirname } from 'pathe';
1
+ import { defineNuxtModule, createResolver, addPlugin, addTemplate, addComponent } from '@nuxt/kit';
2
+ import { schemaOrgComponents, schemaOrgAutoImports } from '@unhead/schema-org-vue';
4
3
 
5
- const Pkg = "@vueuse/schema-org";
6
4
  const module = defineNuxtModule({
7
5
  meta: {
8
6
  configKey: "schemaOrg",
9
7
  compatibility: {
10
- nuxt: ">=3.0.0-rc.9",
8
+ nuxt: "3.0.0",
11
9
  bridge: false
12
10
  }
13
11
  },
14
- async setup(moduleOptions, nuxt) {
15
- const { resolve, resolvePath } = createResolver(import.meta.url);
16
- moduleOptions = resolveUserConfig(moduleOptions);
17
- if (nuxt.options.ssr && !moduleOptions.canonicalHost && !moduleOptions.meta?.host) {
18
- console.warn("WARN [nuxt-schema-org] Please provide a `canonicalHost` to use this module with SSR enabled.");
19
- return;
20
- }
21
- if (!nuxt.options.ssr)
22
- moduleOptions.client = true;
23
- if (typeof moduleOptions.client === "undefined")
24
- moduleOptions.client = !!nuxt.options.dev;
25
- const pkgPath = dirname(await resolvePath(Pkg));
26
- nuxt.options.alias[AliasRuntime] = `${pkgPath}/runtime-${moduleOptions.full ? "schema-dts" : "simple"}`;
12
+ async setup(config, nuxt) {
13
+ const { resolve } = createResolver(import.meta.url);
27
14
  const moduleRuntimeDir = resolve("./runtime");
28
- nuxt.options.build.transpile.push(...[moduleRuntimeDir, AliasRuntime]);
29
- if (!moduleOptions.client)
30
- addPlugin(resolve(moduleRuntimeDir, "plugin-fallback.client"));
15
+ nuxt.options.build.transpile.push(...[
16
+ moduleRuntimeDir,
17
+ "@vueuse/schema-org",
18
+ "@unhead/schema-org-vue"
19
+ ]);
31
20
  addPlugin({
32
21
  src: resolve(moduleRuntimeDir, "plugin"),
33
- mode: moduleOptions.client ? "all" : "server"
22
+ mode: nuxt.options.dev || !nuxt.options.ssr ? "all" : "server"
34
23
  });
35
- addTemplate({
24
+ nuxt.options.alias["#nuxt-schema-org/config"] = addTemplate({
36
25
  filename: "nuxt-schema-org-config.mjs",
37
- getContents: () => `export default ${JSON.stringify(moduleOptions)}`
38
- });
26
+ getContents: () => `export default ${JSON.stringify(config)}`
27
+ }).dst;
39
28
  for (const component of schemaOrgComponents) {
40
29
  await addComponent({
41
30
  name: component,
42
31
  export: component,
43
32
  chunkName: "nuxt-schema-org/components",
44
- filePath: AliasRuntime
33
+ filePath: "@unhead/schema-org-vue"
45
34
  });
46
35
  }
47
36
  nuxt.hooks.hook("imports:sources", (autoImports) => {
48
37
  autoImports.unshift(...schemaOrgAutoImports);
49
38
  });
50
- nuxt.hooks.hook("vite:extendConfig", async (config, { isClient }) => {
51
- config.plugins = config.plugins || [];
52
- const SchemaOrgVite = await importModule(`${pkgPath}/vite`, { interopDefault: true });
53
- config.plugins.push(SchemaOrgVite({
54
- root: nuxt.options.rootDir,
55
- dts: false,
56
- mock: !moduleOptions.client && isClient,
57
- full: moduleOptions.full
58
- }));
59
- });
60
- extendWebpackConfig(async (config) => {
61
- config.plugins = config.plugins || [];
62
- const SchemaOrgWebpack = await importModule(`${pkgPath}/webpack`, { interopDefault: true });
63
- const plugins = SchemaOrgWebpack({
64
- root: nuxt.options.rootDir,
65
- dts: false,
66
- mock: !moduleOptions.client && config.name === "client",
67
- full: moduleOptions.full
68
- });
69
- config.plugins.push(...plugins);
70
- });
71
39
  }
72
40
  });
73
41
 
@@ -1,41 +1,18 @@
1
- import { createSchemaOrg } from "@vueuse/schema-org";
2
- import { defineNuxtPlugin } from "#app";
3
- import { unref, watch } from "#imports";
4
- import config from "#build/nuxt-schema-org-config.mjs";
5
- export default defineNuxtPlugin(async (nuxtApp) => {
6
- const ssr = !!nuxtApp.ssrContext?.url;
7
- const client = createSchemaOrg({
8
- updateHead(fn) {
9
- nuxtApp._useHead(unref(fn));
10
- },
11
- async meta() {
12
- const head = nuxtApp.vueApp._context.provides.usehead;
13
- const inferredMeta = {};
14
- const headTag = head.headTags.reverse().filter((t) => t.tag === "title" && (!!t.props.children || !!t.children));
15
- if (headTag.length)
16
- inferredMeta.title = headTag[0].props.children || headTag[0].children;
17
- const descTag = head.headTags.reverse().filter((t) => t.tag === "meta" && t.props.name === "description" && !!t.props.content);
18
- if (descTag.length)
19
- inferredMeta.description = descTag[0].props.content;
20
- const imageTag = head.headTags.reverse().filter((t) => t.tag === "meta" && t.props.property === "og:image" && !!t.props.content);
21
- if (imageTag.length)
22
- inferredMeta.image = imageTag[0].props.content;
23
- const schemaOrgMeta = {
24
- path: nuxtApp._route.path,
25
- ...inferredMeta,
26
- ...nuxtApp._route.meta,
27
- ...config.meta || {}
28
- };
29
- await nuxtApp.hooks.callHook("schema-org:meta", schemaOrgMeta);
30
- return schemaOrgMeta;
31
- }
32
- });
33
- nuxtApp.vueApp.use(client);
34
- if (ssr) {
35
- await client.forceRefresh();
36
- return;
37
- }
38
- watch(() => nuxtApp._route.path, () => {
39
- client.forceRefresh();
40
- });
1
+ import { SchemaOrgUnheadPlugin } from "@unhead/schema-org-vue";
2
+ import config from "#nuxt-schema-org/config";
3
+ import { defineNuxtPlugin, useRouter } from "#app";
4
+ export default defineNuxtPlugin((nuxtApp) => {
5
+ const head = nuxtApp.vueApp._context.provides.usehead;
6
+ const router = useRouter();
7
+ const currentRoute = router.currentRoute;
8
+ head.use(SchemaOrgUnheadPlugin(config, async () => {
9
+ const route = currentRoute.value;
10
+ const meta = {
11
+ ...config,
12
+ path: route.path,
13
+ ...route.meta
14
+ };
15
+ await nuxtApp.hooks.callHook("schema-org:meta", meta);
16
+ return meta;
17
+ }));
41
18
  });
package/dist/types.d.ts CHANGED
@@ -8,4 +8,4 @@ declare module '@nuxt/schema' {
8
8
  }
9
9
 
10
10
 
11
- export { default } from './module'
11
+ export { ModuleHooks, ModuleOptions, default } from './module'
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-schema-org",
3
3
  "type": "module",
4
- "version": "1.1.0-beta.5",
5
4
  "description": "Nuxt module for @vueuse/schema-org",
6
5
  "author": "Harlan Wilton <harlan@harlanzw.com>",
7
6
  "license": "MIT",
@@ -34,20 +33,20 @@
34
33
  "dist"
35
34
  ],
36
35
  "dependencies": {
37
- "@nuxt/kit": "3.0.0-rc.11",
38
- "@vueuse/schema-org": "1.1.0-beta.5",
39
- "@vueuse/schema-org-vite": "1.1.0-beta.5",
40
- "pathe": "^0.3.9",
41
- "schema-org-graph-js": "0.5.1"
36
+ "@nuxt/kit": "3.0.0",
37
+ "@unhead/schema-org-vue": "latest",
38
+ "pathe": "^1.0.0"
42
39
  },
43
40
  "devDependencies": {
44
- "@nuxt/module-builder": "^0.1.7",
45
- "@nuxt/schema": "3.0.0-rc.11"
41
+ "@nuxt/module-builder": "^0.2.1",
42
+ "@nuxt/schema": "3.0.0",
43
+ "nuxt": "3.0.0"
46
44
  },
45
+ "version": "2.0.0-beta.0",
47
46
  "scripts": {
48
- "build": "npm run -C ../../test/fixtures/nuxt nuxt:prepare && nuxt-module-build",
47
+ "build": "nuxi prepare ../../test/fixtures/nuxt && nuxt-module-build",
49
48
  "stub": "nuxt-module-build --stub && nuxi prepare ../../test/fixtures/nuxt",
50
- "play": "nuxi dev ../../playgrounds/nuxt3",
51
- "play:build": "nuxi build ../../playgrounds/nuxt3"
49
+ "play": "nuxi dev ../../test/fixtures/nuxt",
50
+ "play:build": "nuxi build ../../test/fixtures/nuxt"
52
51
  }
53
52
  }
@@ -1,2 +0,0 @@
1
- declare const _default: any;
2
- export default _default;
@@ -1,7 +0,0 @@
1
- import { defineNuxtPlugin } from "#app";
2
- import { watch } from "#imports";
3
- export default defineNuxtPlugin((nuxtApp) => {
4
- watch(() => nuxtApp._route.path, () => {
5
- document.querySelector('script[data-id="schema-org-graph"]')?.remove();
6
- });
7
- });