nuxt-site-config 0.5.2 → 0.5.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/build.d.ts CHANGED
@@ -1,6 +1,4 @@
1
- import { S as SiteConfig, a as SiteConfigInput } from './type-6889825a.js';
2
- export { b as MaybeComputedRef, c as MaybeComputedRefEntries, M as MaybeReadonlyRef, d as SiteConfigContainer, e as SiteConfigReactiveContainer } from './type-6889825a.js';
3
- import 'vue';
1
+ import { S as SiteConfig, a as SiteConfigInput } from './type-3a82b30b.js';
4
2
 
5
3
  declare function initSiteConfig(): Promise<SiteConfig>;
6
4
  declare function updateSiteConfig(siteConfig: SiteConfigInput): Promise<void>;
@@ -16,4 +14,4 @@ declare function assertSiteConfig(mode: AssertionModes, options?: {
16
14
  messages: string[];
17
15
  }>;
18
16
 
19
- export { SiteConfig, SiteConfigInput, assertSiteConfig, initSiteConfig, requireSiteConfig, updateSiteConfig, useSiteConfig };
17
+ export { assertSiteConfig, initSiteConfig, requireSiteConfig, updateSiteConfig, useSiteConfig };
package/dist/build.mjs CHANGED
@@ -44,10 +44,10 @@ const envSiteConfig = {
44
44
  name: envShim.NUXT_PUBLIC_SITE_NAME,
45
45
  description: envShim.NUXT_PUBLIC_SITE_DESCRIPTION,
46
46
  logo: envShim.NUXT_PUBLIC_SITE_IMAGE,
47
- index: envShim.NUXT_PUBLIC_SITE_INDEX,
47
+ indexable: envShim.NUXT_PUBLIC_SITE_INDEXABLE || envShim.NUXT_PUBLIC_SITE_INDEX,
48
48
  titleSeparator: envShim.NUXT_PUBLIC_SITE_TITLE_SEPARATOR,
49
49
  trailingSlash: envShim.NUXT_PUBLIC_SITE_TRAILING_SLASH,
50
- language: envShim.NUXT_PUBLIC_SITE_LANGUAGE
50
+ locale: envShim.NUXT_PUBLIC_SITE_LANGUAGE || envShim.NUXT_PUBLIC_SITE_LOCALE
51
51
  };
52
52
 
53
53
  let siteConfigContainer;
package/dist/module.d.ts CHANGED
@@ -1,13 +1,28 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
- import { S as SiteConfig, a as SiteConfigInput } from './type-6889825a.js';
3
- export { b as MaybeComputedRef, c as MaybeComputedRefEntries, M as MaybeReadonlyRef, d as SiteConfigContainer, e as SiteConfigReactiveContainer } from './type-6889825a.js';
4
- import 'vue';
2
+ import { b as SiteConfigContainer, a as SiteConfigInput, S as SiteConfig } from './type-3a82b30b.js';
5
3
 
6
4
  interface ModuleOptions extends SiteConfigInput {
7
5
  }
8
6
  interface ModulePublicRuntimeConfig {
9
7
  site: SiteConfigInput;
10
8
  }
9
+ declare module 'h3' {
10
+ interface H3EventContext {
11
+ siteConfig: SiteConfigContainer;
12
+ }
13
+ }
14
+ declare module 'nuxt/schema' {
15
+ interface AppConfigInput {
16
+ /** Theme configuration */
17
+ site?: SiteConfigInput;
18
+ }
19
+ }
20
+ declare module '@nuxt/schema' {
21
+ interface AppConfigInput {
22
+ /** Theme configuration */
23
+ site?: SiteConfigInput;
24
+ }
25
+ }
11
26
  declare module '@nuxt/schema' {
12
27
  interface RuntimeNuxtHooks {
13
28
  'site-config:resolve': (siteConfig: SiteConfig) => void;
@@ -18,4 +33,4 @@ interface ModuleHooks {
18
33
  }
19
34
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
20
35
 
21
- export { ModuleHooks, ModuleOptions, ModulePublicRuntimeConfig, SiteConfig, SiteConfigInput, _default as default };
36
+ export { ModuleHooks, ModuleOptions, ModulePublicRuntimeConfig, _default as default };
package/dist/module.json CHANGED
@@ -5,5 +5,5 @@
5
5
  "bridge": false
6
6
  },
7
7
  "configKey": "site",
8
- "version": "0.5.2"
8
+ "version": "0.5.4"
9
9
  }
package/dist/module.mjs CHANGED
@@ -69,7 +69,7 @@ const module = defineNuxtModule({
69
69
  }
70
70
  ]);
71
71
  addPlugin({
72
- src: resolve("./runtime/plugins/siteConfig.ts")
72
+ src: resolve("./runtime/plugins/siteConfig")
73
73
  });
74
74
  addServerHandler({
75
75
  middleware: true,
@@ -1,2 +1,2 @@
1
- import type { MaybeComputedRefEntries, SiteConfigInput } from '../../type';
2
- export declare function updateSiteConfig(input?: MaybeComputedRefEntries<SiteConfigInput>): void;
1
+ import type { SiteConfigInput } from '../../type';
2
+ export declare function updateSiteConfig(input?: SiteConfigInput): void;
@@ -1,15 +1,10 @@
1
- import { unref, useNuxtApp, useRequestEvent } from "#imports";
1
+ import { useNuxtApp, useRequestEvent } from "#imports";
2
2
  export function updateSiteConfig(input = {}) {
3
- const unrefdInput = unref(input);
4
- for (const k of Object.keys(unrefdInput)) {
5
- unrefdInput[k] = unref(unrefdInput[k]);
6
- }
7
- const resolvedInput = unrefdInput;
8
3
  if (process.server) {
9
4
  const container2 = useRequestEvent().context.siteConfig;
10
- container2.push(resolvedInput);
5
+ container2.push(input);
11
6
  return;
12
7
  }
13
8
  const container = useNuxtApp().$siteConfig;
14
- container.push(resolvedInput);
9
+ container.push(input);
15
10
  }
@@ -25,6 +25,6 @@ export function createInternalLinkResolver(options = {}) {
25
25
  path = fixSlashes(siteConfig.trailingSlash, path);
26
26
  if (!options.absolute)
27
27
  return path;
28
- return withBase(path, siteConfig.value.url || "/");
28
+ return withBase(path, siteConfig.url || "/");
29
29
  };
30
30
  }
@@ -1,2 +1,2 @@
1
- import type { SiteConfigInput } from '../type';
1
+ import type { SiteConfigInput } from '../../type';
2
2
  export declare const envSiteConfig: SiteConfigInput;
@@ -14,8 +14,8 @@ export const envSiteConfig = {
14
14
  name: envShim.NUXT_PUBLIC_SITE_NAME,
15
15
  description: envShim.NUXT_PUBLIC_SITE_DESCRIPTION,
16
16
  logo: envShim.NUXT_PUBLIC_SITE_IMAGE,
17
- index: envShim.NUXT_PUBLIC_SITE_INDEX,
17
+ indexable: envShim.NUXT_PUBLIC_SITE_INDEXABLE || envShim.NUXT_PUBLIC_SITE_INDEX,
18
18
  titleSeparator: envShim.NUXT_PUBLIC_SITE_TITLE_SEPARATOR,
19
19
  trailingSlash: envShim.NUXT_PUBLIC_SITE_TRAILING_SLASH,
20
- language: envShim.NUXT_PUBLIC_SITE_LANGUAGE
20
+ locale: envShim.NUXT_PUBLIC_SITE_LANGUAGE || envShim.NUXT_PUBLIC_SITE_LOCALE
21
21
  };
@@ -1,5 +1,3 @@
1
- import { ComputedRef, Ref } from 'vue';
2
-
3
1
  interface SiteConfig {
4
2
  /**
5
3
  * The canonical Site URL.
@@ -56,24 +54,9 @@ interface SiteConfigInput {
56
54
  indexable?: boolean | string;
57
55
  trailingSlash?: boolean | string;
58
56
  }
59
- declare module 'nuxt/schema' {
60
- interface AppConfigInput {
61
- /** Theme configuration */
62
- site?: SiteConfigInput;
63
- }
64
- }
65
- type MaybeReadonlyRef<T> = (() => T) | ComputedRef<T>;
66
- type MaybeComputedRef<T> = T | MaybeReadonlyRef<T> | Ref<T>;
67
- type MaybeComputedRefEntries<T> = MaybeComputedRef<T> | {
68
- [key in keyof T]?: MaybeComputedRef<T[key]>;
69
- };
70
57
  interface SiteConfigContainer {
71
58
  push: (config: SiteConfigInput) => void;
72
59
  get: () => SiteConfig;
73
60
  }
74
- interface SiteConfigReactiveContainer {
75
- push: (config: MaybeComputedRefEntries<SiteConfigInput>) => () => void;
76
- get: () => Ref<SiteConfig>;
77
- }
78
61
 
79
- export { MaybeReadonlyRef as M, SiteConfig as S, SiteConfigInput as a, MaybeComputedRef as b, MaybeComputedRefEntries as c, SiteConfigContainer as d, SiteConfigReactiveContainer as e };
62
+ export { SiteConfig as S, SiteConfigInput as a, SiteConfigContainer as b };
package/dist/types.d.ts CHANGED
@@ -16,4 +16,4 @@ declare module 'nuxt/schema' {
16
16
  }
17
17
 
18
18
 
19
- export { MaybeComputedRef, MaybeComputedRefEntries, MaybeReadonlyRef, SiteConfigContainer, SiteConfigReactiveContainer } from './module'
19
+ export { ModuleHooks, ModuleOptions, ModulePublicRuntimeConfig, default } from './module'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-site-config",
3
3
  "type": "module",
4
- "version": "0.5.2",
4
+ "version": "0.5.4",
5
5
  "packageManager": "pnpm@8.6.3",
6
6
  "description": "Shared site configuration for Nuxt 3 modules.",
7
7
  "license": "MIT",
@@ -1,5 +0,0 @@
1
- import type { SiteConfigReactiveContainer } from '../../type';
2
- /**
3
- * @todo support reactivity
4
- */
5
- export declare function createReactiveSiteConfigContainer(): SiteConfigReactiveContainer;
@@ -1,41 +0,0 @@
1
- import { defu } from "defu";
2
- import { ref, shallowRef, unref, watch, watchEffect } from "vue";
3
- import { normalizeSiteConfig } from ".//index.mjs";
4
- export function createReactiveSiteConfigContainer() {
5
- let count = 0;
6
- const stack = shallowRef([]);
7
- function push(input) {
8
- const unrefdInput = {};
9
- const unrefdOverrides = unref(input);
10
- for (const k of Object.keys(unrefdOverrides)) {
11
- unrefdInput[k] = unref(unrefdOverrides[k]);
12
- }
13
- const id = count++;
14
- function cleanUp() {
15
- stack.value = stack.value.filter((o) => o._id !== id);
16
- }
17
- stack.value.push({ ...unrefdInput, _id: id });
18
- watch(() => unrefdInput, (input2) => {
19
- cleanUp();
20
- push(input2);
21
- }, {
22
- deep: true
23
- });
24
- return cleanUp;
25
- }
26
- function get() {
27
- const siteConfig = ref({});
28
- watchEffect(() => {
29
- const inputs = stack.value;
30
- let mergedStack = {};
31
- for (const o of inputs)
32
- mergedStack = defu(o, mergedStack);
33
- siteConfig.value = normalizeSiteConfig(mergedStack);
34
- });
35
- return siteConfig;
36
- }
37
- return {
38
- push,
39
- get
40
- };
41
- }