nuxt-site-config 0.8.2 → 0.8.4
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.json +1 -1
- package/dist/module.mjs +9 -13
- package/dist/runtime/composables/utils.d.ts +2 -0
- package/dist/runtime/composables/utils.mjs +5 -3
- package/dist/runtime/nitro/composables/utils.d.ts +1 -0
- package/dist/runtime/nitro/composables/utils.mjs +1 -1
- package/dist/runtime/nitro/middleware/init.mjs +3 -1
- package/package.json +3 -3
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -12,13 +12,6 @@ const module = defineNuxtModule({
|
|
|
12
12
|
},
|
|
13
13
|
async setup(config, nuxt) {
|
|
14
14
|
const { resolve } = createResolver(import.meta.url);
|
|
15
|
-
const composables = ["useSiteConfig", "updateSiteConfig", "useNitroOrigin"];
|
|
16
|
-
composables.forEach((c) => {
|
|
17
|
-
addImports({
|
|
18
|
-
from: resolve(`./runtime/composables/${c}`),
|
|
19
|
-
name: c
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
15
|
await initSiteConfig();
|
|
23
16
|
nuxt.hook("modules:done", async () => {
|
|
24
17
|
await updateSiteConfig({
|
|
@@ -29,9 +22,11 @@ const module = defineNuxtModule({
|
|
|
29
22
|
await nuxt.callHook("site-config:resolve", siteConfig);
|
|
30
23
|
nuxt.options.runtimeConfig.public.site = siteConfig;
|
|
31
24
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
const composables = ["useSiteConfig", "updateSiteConfig", "useNitroOrigin"];
|
|
26
|
+
composables.forEach((c) => {
|
|
27
|
+
addImports({
|
|
28
|
+
from: resolve(`./runtime/composables/${c}`),
|
|
29
|
+
name: c
|
|
35
30
|
});
|
|
36
31
|
});
|
|
37
32
|
const linkComposables = ["createSitePathResolver", "withSiteTrailingSlash", "withSiteUrl"];
|
|
@@ -41,9 +36,10 @@ const module = defineNuxtModule({
|
|
|
41
36
|
name: c
|
|
42
37
|
});
|
|
43
38
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
nuxt.hooks.hook("nitro:init", async (nitro) => {
|
|
40
|
+
nitro.hooks.hookOnce("prerender:generate", async () => {
|
|
41
|
+
await assertSiteConfig("prerender");
|
|
42
|
+
});
|
|
47
43
|
});
|
|
48
44
|
await addComponent({
|
|
49
45
|
filePath: resolve("./runtime/component/SiteLink.vue"),
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { MaybeRef } from '@vue/reactivity';
|
|
2
2
|
export declare function createSitePathResolver(options?: {
|
|
3
|
+
canonical?: MaybeRef<boolean>;
|
|
3
4
|
absolute?: MaybeRef<boolean>;
|
|
4
5
|
withBase?: MaybeRef<boolean>;
|
|
5
6
|
}): (path: MaybeRef<string>) => any;
|
|
6
7
|
export declare function withSiteTrailingSlash(path: MaybeRef<string>): any;
|
|
7
8
|
export declare function withSiteUrl(path: MaybeRef<string>, options?: {
|
|
9
|
+
canonical?: MaybeRef<boolean>;
|
|
8
10
|
withBase?: boolean;
|
|
9
11
|
}): any;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { fixSlashes, resolveSitePath } from "site-config-stack";
|
|
2
|
-
import { computed, unref, useRuntimeConfig, useSiteConfig } from "#imports";
|
|
2
|
+
import { computed, unref, useNitroOrigin, useRuntimeConfig, useSiteConfig } from "#imports";
|
|
3
3
|
export function createSitePathResolver(options = {}) {
|
|
4
4
|
const siteConfig = useSiteConfig();
|
|
5
|
+
const nitroOrigin = useNitroOrigin();
|
|
5
6
|
const nuxtBase = useRuntimeConfig().app.baseURL || "/";
|
|
6
7
|
return (path) => {
|
|
7
8
|
return computed(() => resolveSitePath(unref(path), {
|
|
8
9
|
absolute: unref(options.absolute),
|
|
9
10
|
withBase: unref(options.withBase),
|
|
10
|
-
siteUrl: siteConfig.url,
|
|
11
|
+
siteUrl: unref(options.canonical) !== false || process.env.prerender ? siteConfig.url : nitroOrigin,
|
|
11
12
|
trailingSlash: siteConfig.trailingSlash,
|
|
12
13
|
base: nuxtBase
|
|
13
14
|
}));
|
|
@@ -21,11 +22,12 @@ export function withSiteTrailingSlash(path) {
|
|
|
21
22
|
}
|
|
22
23
|
export function withSiteUrl(path, options = {}) {
|
|
23
24
|
const siteConfig = useSiteConfig();
|
|
25
|
+
const nitroOrigin = useNitroOrigin();
|
|
24
26
|
const base = useRuntimeConfig().app.baseURL || "/";
|
|
25
27
|
return computed(() => {
|
|
26
28
|
return resolveSitePath(unref(path), {
|
|
27
29
|
absolute: true,
|
|
28
|
-
siteUrl: siteConfig.url,
|
|
30
|
+
siteUrl: unref(options.canonical) !== false || process.env.prerender ? siteConfig.url : nitroOrigin,
|
|
29
31
|
trailingSlash: siteConfig.trailingSlash,
|
|
30
32
|
base,
|
|
31
33
|
withBase: options.withBase
|
|
@@ -7,7 +7,7 @@ export function withSiteUrl(e, path, options = {}) {
|
|
|
7
7
|
const siteConfig = e.context.siteConfig?.get();
|
|
8
8
|
return resolveSitePath(path, {
|
|
9
9
|
absolute: true,
|
|
10
|
-
siteUrl: siteConfig.url
|
|
10
|
+
siteUrl: options.canonical !== false || process.env.prerender ? siteConfig.url : e.context.siteConfigNitroOrigin,
|
|
11
11
|
trailingSlash: siteConfig.trailingSlash,
|
|
12
12
|
base: e.context.nitro.baseURL,
|
|
13
13
|
withBase: options.withBase
|
|
@@ -2,10 +2,12 @@ import { eventHandler, updateSiteConfig, useAppConfig, useNitroOrigin, useRuntim
|
|
|
2
2
|
export default eventHandler((e) => {
|
|
3
3
|
if (!e.context.siteConfig) {
|
|
4
4
|
const appConfig = useAppConfig();
|
|
5
|
+
const nitroOrigin = useNitroOrigin(e);
|
|
6
|
+
e.context.siteConfigNitroOrigin = nitroOrigin;
|
|
5
7
|
const { public: publicRuntimeConfig } = useRuntimeConfig();
|
|
6
8
|
updateSiteConfig(e, {
|
|
7
9
|
_context: "nitro:init",
|
|
8
|
-
url:
|
|
10
|
+
url: nitroOrigin
|
|
9
11
|
});
|
|
10
12
|
updateSiteConfig(e, publicRuntimeConfig.site);
|
|
11
13
|
if (appConfig.site) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-site-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.4",
|
|
5
5
|
"packageManager": "pnpm@8.6.5",
|
|
6
6
|
"description": "Shared site configuration for Nuxt 3 modules.",
|
|
7
7
|
"license": "MIT",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@nuxt/kit": "3.6.1",
|
|
31
31
|
"ufo": "^1.1.2",
|
|
32
|
-
"nuxt-site-config-kit": "0.8.
|
|
33
|
-
"site-config-stack": "0.8.
|
|
32
|
+
"nuxt-site-config-kit": "0.8.4",
|
|
33
|
+
"site-config-stack": "0.8.4"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "nuxt-module-build --stub && nuxt-module-build prepare && nuxt-module-build",
|