site-config-stack 0.7.5 → 0.8.1
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 +16 -0
- package/dist/index.d.ts +15 -6
- package/dist/index.mjs +15 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const ufo = require('ufo');
|
|
4
|
+
|
|
3
5
|
const processShim = typeof process !== "undefined" ? process : {};
|
|
4
6
|
const envShim = processShim.env || {};
|
|
5
7
|
const envSiteConfig = {
|
|
@@ -63,7 +65,21 @@ function normalizeSiteConfig(config) {
|
|
|
63
65
|
config.trailingSlash = String(config.trailingSlash) !== "false";
|
|
64
66
|
return config;
|
|
65
67
|
}
|
|
68
|
+
function resolveSitePath(path, options) {
|
|
69
|
+
const origin = options.absolute ? options.siteUrl : "";
|
|
70
|
+
const baseWithOrigin = options.withBase ? ufo.joinURL(origin || "/", options.base) : origin;
|
|
71
|
+
const resolvedUrl = ufo.joinURL(baseWithOrigin, path);
|
|
72
|
+
return fixSlashes(options.trailingSlash, resolvedUrl);
|
|
73
|
+
}
|
|
74
|
+
function fixSlashes(trailingSlash, path) {
|
|
75
|
+
const isFileUrl = path.includes(".");
|
|
76
|
+
if (isFileUrl)
|
|
77
|
+
return path;
|
|
78
|
+
return trailingSlash ? ufo.withTrailingSlash(path) : ufo.withoutTrailingSlash(path);
|
|
79
|
+
}
|
|
66
80
|
|
|
67
81
|
exports.createSiteConfigStack = createSiteConfigStack;
|
|
68
82
|
exports.envSiteConfig = envSiteConfig;
|
|
83
|
+
exports.fixSlashes = fixSlashes;
|
|
69
84
|
exports.normalizeSiteConfig = normalizeSiteConfig;
|
|
85
|
+
exports.resolveSitePath = resolveSitePath;
|
package/dist/index.d.ts
CHANGED
|
@@ -11,10 +11,10 @@ interface SiteConfig {
|
|
|
11
11
|
* Used by: nuxt-simple-sitemap, nuxt-simple-robots, nuxt-schema-org, nuxt-og-image, etc.
|
|
12
12
|
*/
|
|
13
13
|
url?: string;
|
|
14
|
-
titleSeparator
|
|
15
|
-
indexable
|
|
16
|
-
trailingSlash
|
|
17
|
-
locale
|
|
14
|
+
titleSeparator: string;
|
|
15
|
+
indexable: boolean;
|
|
16
|
+
trailingSlash: boolean;
|
|
17
|
+
locale: string;
|
|
18
18
|
/**
|
|
19
19
|
* The name of the site.
|
|
20
20
|
*
|
|
@@ -25,7 +25,7 @@ interface SiteConfig {
|
|
|
25
25
|
*
|
|
26
26
|
* Used by: nuxt-schema-org, nuxt-seo-kit
|
|
27
27
|
*/
|
|
28
|
-
name
|
|
28
|
+
name: string;
|
|
29
29
|
/**
|
|
30
30
|
* The description of the site.
|
|
31
31
|
*
|
|
@@ -42,6 +42,7 @@ interface SiteConfig {
|
|
|
42
42
|
* Used by: nuxt-schema-org, nuxt-seo-kit
|
|
43
43
|
*/
|
|
44
44
|
logo?: string;
|
|
45
|
+
coverImage?: string;
|
|
45
46
|
/**
|
|
46
47
|
* The mapping of the context of each site config value being set.
|
|
47
48
|
*/
|
|
@@ -72,5 +73,13 @@ declare const envSiteConfig: SiteConfigInput;
|
|
|
72
73
|
declare function createSiteConfigStack(): SiteConfigStack;
|
|
73
74
|
|
|
74
75
|
declare function normalizeSiteConfig(config: SiteConfig): SiteConfig;
|
|
76
|
+
declare function resolveSitePath(path: string, options: {
|
|
77
|
+
siteUrl: string;
|
|
78
|
+
trailingSlash: boolean;
|
|
79
|
+
base: string;
|
|
80
|
+
absolute?: boolean;
|
|
81
|
+
withBase?: boolean;
|
|
82
|
+
}): string;
|
|
83
|
+
declare function fixSlashes(trailingSlash: boolean, path: string): string;
|
|
75
84
|
|
|
76
|
-
export { SiteConfig, SiteConfigInput, SiteConfigStack, createSiteConfigStack, envSiteConfig, normalizeSiteConfig };
|
|
85
|
+
export { SiteConfig, SiteConfigInput, SiteConfigStack, createSiteConfigStack, envSiteConfig, fixSlashes, normalizeSiteConfig, resolveSitePath };
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { joinURL, withTrailingSlash, withoutTrailingSlash } from 'ufo';
|
|
2
|
+
|
|
1
3
|
const processShim = typeof process !== "undefined" ? process : {};
|
|
2
4
|
const envShim = processShim.env || {};
|
|
3
5
|
const envSiteConfig = {
|
|
@@ -61,5 +63,17 @@ function normalizeSiteConfig(config) {
|
|
|
61
63
|
config.trailingSlash = String(config.trailingSlash) !== "false";
|
|
62
64
|
return config;
|
|
63
65
|
}
|
|
66
|
+
function resolveSitePath(path, options) {
|
|
67
|
+
const origin = options.absolute ? options.siteUrl : "";
|
|
68
|
+
const baseWithOrigin = options.withBase ? joinURL(origin || "/", options.base) : origin;
|
|
69
|
+
const resolvedUrl = joinURL(baseWithOrigin, path);
|
|
70
|
+
return fixSlashes(options.trailingSlash, resolvedUrl);
|
|
71
|
+
}
|
|
72
|
+
function fixSlashes(trailingSlash, path) {
|
|
73
|
+
const isFileUrl = path.includes(".");
|
|
74
|
+
if (isFileUrl)
|
|
75
|
+
return path;
|
|
76
|
+
return trailingSlash ? withTrailingSlash(path) : withoutTrailingSlash(path);
|
|
77
|
+
}
|
|
64
78
|
|
|
65
|
-
export { createSiteConfigStack, envSiteConfig, normalizeSiteConfig };
|
|
79
|
+
export { createSiteConfigStack, envSiteConfig, fixSlashes, normalizeSiteConfig, resolveSitePath };
|