site-config-stack 0.8.17 → 1.0.2

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/index.cjs CHANGED
@@ -2,29 +2,6 @@
2
2
 
3
3
  const ufo = require('ufo');
4
4
 
5
- const processShim = typeof process !== "undefined" ? process : {};
6
- const envShim = processShim.env || {};
7
- const envSiteConfig = {
8
- _context: "env",
9
- url: [
10
- envShim.NUXT_PUBLIC_VERCEL_URL,
11
- // vercel
12
- envShim.NUXT_PUBLIC_URL,
13
- // netlify
14
- envShim.NUXT_PUBLIC_CF_PAGES_URL,
15
- // cloudflare pages
16
- envShim.NUXT_PUBLIC_SITE_URL
17
- // nuxt-site-config
18
- ].find((k) => Boolean(k)),
19
- name: envShim.NUXT_PUBLIC_SITE_NAME,
20
- description: envShim.NUXT_PUBLIC_SITE_DESCRIPTION,
21
- logo: envShim.NUXT_PUBLIC_SITE_IMAGE,
22
- indexable: envShim.NUXT_PUBLIC_SITE_INDEXABLE || envShim.NUXT_PUBLIC_SITE_INDEX,
23
- titleSeparator: envShim.NUXT_PUBLIC_SITE_TITLE_SEPARATOR,
24
- trailingSlash: envShim.NUXT_PUBLIC_SITE_TRAILING_SLASH,
25
- locale: envShim.NUXT_PUBLIC_SITE_LANGUAGE || envShim.NUXT_PUBLIC_SITE_LOCALE
26
- };
27
-
28
5
  function createSiteConfigStack() {
29
6
  const stack = [];
30
7
  function push(input) {
@@ -55,6 +32,7 @@ function createSiteConfigStack() {
55
32
  return normalizeSiteConfig(siteConfig);
56
33
  }
57
34
  return {
35
+ stack,
58
36
  push,
59
37
  get
60
38
  };
@@ -93,7 +71,6 @@ function fixSlashes(trailingSlash, pathOrUrl) {
93
71
  }
94
72
 
95
73
  exports.createSiteConfigStack = createSiteConfigStack;
96
- exports.envSiteConfig = envSiteConfig;
97
74
  exports.fixSlashes = fixSlashes;
98
75
  exports.normalizeSiteConfig = normalizeSiteConfig;
99
76
  exports.resolveSitePath = resolveSitePath;
package/dist/index.d.ts CHANGED
@@ -2,8 +2,6 @@ interface SiteConfig {
2
2
  /**
3
3
  * The canonical Site URL.
4
4
  *
5
- * @default `process.env.NUXT_PUBLIC_SITE_URL`
6
- *
7
5
  * - Build / Prerender: Inferred from CI environment (Netlify, Vercel)
8
6
  * - SSR: Inferred from request headers
9
7
  * - SPA: Inferred from `window.location`
@@ -11,21 +9,31 @@ interface SiteConfig {
11
9
  * Used by: nuxt-simple-sitemap, nuxt-simple-robots, nuxt-schema-org, nuxt-og-image, etc.
12
10
  */
13
11
  url?: string;
14
- titleSeparator: string;
15
- indexable: boolean;
16
- trailingSlash: boolean;
17
- locale: string;
18
12
  /**
19
13
  * The name of the site.
20
14
  *
21
- * @default `process.env.NUXT_PUBLIC_SITE_NAME`
22
- *
23
15
  * - Build / Prerender: Inferred from CI environment (Netlify) or `package.json`
24
16
  * - SSR:
25
17
  *
26
18
  * Used by: nuxt-schema-org, nuxt-seo-kit
27
19
  */
28
20
  name: string;
21
+ /**
22
+ * The title separator of the site.
23
+ */
24
+ titleSeparator: string;
25
+ /**
26
+ * Whether the site is indexable by search engines.
27
+ */
28
+ indexable: boolean;
29
+ /**
30
+ * Whether the site uses trailing slash.
31
+ */
32
+ trailingSlash: boolean;
33
+ /**
34
+ * The default locale of the site.
35
+ */
36
+ defaultLocale: string;
29
37
  /**
30
38
  * The description of the site.
31
39
  *
@@ -34,42 +42,21 @@ interface SiteConfig {
34
42
  * Used by: nuxt-schema-org, nuxt-seo-kit
35
43
  */
36
44
  description?: string;
37
- /**
38
- * The logo of the site.
39
- *
40
- * @default `process.env.NUXT_PUBLIC_SITE_LOGO`
41
- *
42
- * Used by: nuxt-schema-org, nuxt-seo-kit
43
- */
44
- logo?: string;
45
- coverImage?: string;
46
45
  /**
47
46
  * The mapping of the context of each site config value being set.
48
47
  */
49
48
  _context: Partial<Record<Exclude<keyof SiteConfig, '_meta'>, string>>;
49
+ [key: string]: any;
50
50
  }
51
- interface SiteConfigInput {
52
- /**
53
- * A description of the context which added the config.
54
- */
51
+ type SiteConfigInput = Partial<Omit<SiteConfig, '_context'>> & {
55
52
  _context?: string;
56
- url?: string;
57
- name?: string;
58
- description?: string;
59
- logo?: string;
60
- coverImage?: string;
61
- titleSeparator?: string;
62
- locale?: string;
63
- indexable?: boolean | string;
64
- trailingSlash?: boolean | string;
65
- }
53
+ };
66
54
  interface SiteConfigStack {
55
+ stack: Partial<SiteConfigInput>[];
67
56
  push: (config: SiteConfigInput) => void;
68
57
  get: () => SiteConfig;
69
58
  }
70
59
 
71
- declare const envSiteConfig: SiteConfigInput;
72
-
73
60
  declare function createSiteConfigStack(): SiteConfigStack;
74
61
 
75
62
  declare function normalizeSiteConfig(config: SiteConfig): SiteConfig;
@@ -82,4 +69,4 @@ declare function resolveSitePath(pathOrUrl: string, options: {
82
69
  }): string;
83
70
  declare function fixSlashes(trailingSlash: boolean, pathOrUrl: string): string;
84
71
 
85
- export { SiteConfig, SiteConfigInput, SiteConfigStack, createSiteConfigStack, envSiteConfig, fixSlashes, normalizeSiteConfig, resolveSitePath };
72
+ export { SiteConfig, SiteConfigInput, SiteConfigStack, createSiteConfigStack, fixSlashes, normalizeSiteConfig, resolveSitePath };
package/dist/index.mjs CHANGED
@@ -1,28 +1,5 @@
1
1
  import { hasProtocol, withHttps, parseURL, withLeadingSlash, withBase, withTrailingSlash, withoutTrailingSlash } from 'ufo';
2
2
 
3
- const processShim = typeof process !== "undefined" ? process : {};
4
- const envShim = processShim.env || {};
5
- const envSiteConfig = {
6
- _context: "env",
7
- url: [
8
- envShim.NUXT_PUBLIC_VERCEL_URL,
9
- // vercel
10
- envShim.NUXT_PUBLIC_URL,
11
- // netlify
12
- envShim.NUXT_PUBLIC_CF_PAGES_URL,
13
- // cloudflare pages
14
- envShim.NUXT_PUBLIC_SITE_URL
15
- // nuxt-site-config
16
- ].find((k) => Boolean(k)),
17
- name: envShim.NUXT_PUBLIC_SITE_NAME,
18
- description: envShim.NUXT_PUBLIC_SITE_DESCRIPTION,
19
- logo: envShim.NUXT_PUBLIC_SITE_IMAGE,
20
- indexable: envShim.NUXT_PUBLIC_SITE_INDEXABLE || envShim.NUXT_PUBLIC_SITE_INDEX,
21
- titleSeparator: envShim.NUXT_PUBLIC_SITE_TITLE_SEPARATOR,
22
- trailingSlash: envShim.NUXT_PUBLIC_SITE_TRAILING_SLASH,
23
- locale: envShim.NUXT_PUBLIC_SITE_LANGUAGE || envShim.NUXT_PUBLIC_SITE_LOCALE
24
- };
25
-
26
3
  function createSiteConfigStack() {
27
4
  const stack = [];
28
5
  function push(input) {
@@ -53,6 +30,7 @@ function createSiteConfigStack() {
53
30
  return normalizeSiteConfig(siteConfig);
54
31
  }
55
32
  return {
33
+ stack,
56
34
  push,
57
35
  get
58
36
  };
@@ -90,4 +68,4 @@ function fixSlashes(trailingSlash, pathOrUrl) {
90
68
  return trailingSlash ? withTrailingSlash(pathOrUrl) : withoutTrailingSlash(pathOrUrl);
91
69
  }
92
70
 
93
- export { createSiteConfigStack, envSiteConfig, fixSlashes, normalizeSiteConfig, resolveSitePath };
71
+ export { createSiteConfigStack, fixSlashes, normalizeSiteConfig, resolveSitePath };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "site-config-stack",
3
3
  "type": "module",
4
- "version": "0.8.17",
4
+ "version": "1.0.2",
5
5
  "description": "Shared site configuration utilities.",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",