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 +2 -3
- package/dist/module.json +2 -2
- package/dist/module.mjs +15 -47
- package/dist/runtime/plugin.mjs +17 -40
- package/dist/types.d.ts +1 -1
- package/package.json +10 -11
- package/dist/runtime/plugin-fallback.client.d.ts +0 -2
- package/dist/runtime/plugin-fallback.client.mjs +0 -7
package/dist/module.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { UserConfig } from '@
|
|
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
package/dist/module.mjs
CHANGED
|
@@ -1,73 +1,41 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, addPlugin, addTemplate, addComponent
|
|
2
|
-
import {
|
|
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: "
|
|
8
|
+
nuxt: "3.0.0",
|
|
11
9
|
bridge: false
|
|
12
10
|
}
|
|
13
11
|
},
|
|
14
|
-
async setup(
|
|
15
|
-
const { resolve
|
|
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(...[
|
|
29
|
-
|
|
30
|
-
|
|
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:
|
|
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(
|
|
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:
|
|
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
|
|
package/dist/runtime/plugin.mjs
CHANGED
|
@@ -1,41 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
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
|
|
38
|
-
"@
|
|
39
|
-
"
|
|
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
|
|
45
|
-
"@nuxt/schema": "3.0.0
|
|
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": "
|
|
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 ../../
|
|
51
|
-
"play:build": "nuxi build ../../
|
|
49
|
+
"play": "nuxi dev ../../test/fixtures/nuxt",
|
|
50
|
+
"play:build": "nuxi build ../../test/fixtures/nuxt"
|
|
52
51
|
}
|
|
53
52
|
}
|