@barodoc/core 0.0.1 → 1.0.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/LICENSE +1 -1
- package/dist/{chunk-JQRBNHRZ.js → chunk-UNDAI47C.js} +5 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.js +1 -1
- package/dist/index.js +25 -6
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -35,6 +35,10 @@ var topbarSchema = z.object({
|
|
|
35
35
|
var searchSchema = z.object({
|
|
36
36
|
enabled: z.boolean().optional()
|
|
37
37
|
}).optional();
|
|
38
|
+
var pluginConfigSchema = z.union([
|
|
39
|
+
z.string(),
|
|
40
|
+
z.tuple([z.string(), z.record(z.unknown())])
|
|
41
|
+
]);
|
|
38
42
|
var barodocConfigSchema = z.object({
|
|
39
43
|
name: z.string(),
|
|
40
44
|
logo: z.string().optional(),
|
|
@@ -44,6 +48,7 @@ var barodocConfigSchema = z.object({
|
|
|
44
48
|
navigation: z.array(navItemSchema),
|
|
45
49
|
topbar: topbarSchema,
|
|
46
50
|
search: searchSchema,
|
|
51
|
+
plugins: z.array(pluginConfigSchema).optional(),
|
|
47
52
|
customCss: z.array(z.string()).optional()
|
|
48
53
|
});
|
|
49
54
|
|
package/dist/config/index.d.ts
CHANGED
|
@@ -122,6 +122,7 @@ declare const barodocConfigSchema: z.ZodObject<{
|
|
|
122
122
|
}, {
|
|
123
123
|
enabled?: boolean | undefined;
|
|
124
124
|
}>>;
|
|
125
|
+
plugins: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>], null>]>, "many">>;
|
|
125
126
|
customCss: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
126
127
|
}, "strip", z.ZodTypeAny, {
|
|
127
128
|
name: string;
|
|
@@ -161,6 +162,7 @@ declare const barodocConfigSchema: z.ZodObject<{
|
|
|
161
162
|
search?: {
|
|
162
163
|
enabled?: boolean | undefined;
|
|
163
164
|
} | undefined;
|
|
165
|
+
plugins?: (string | [string, Record<string, unknown>])[] | undefined;
|
|
164
166
|
customCss?: string[] | undefined;
|
|
165
167
|
}, {
|
|
166
168
|
name: string;
|
|
@@ -200,6 +202,7 @@ declare const barodocConfigSchema: z.ZodObject<{
|
|
|
200
202
|
search?: {
|
|
201
203
|
enabled?: boolean | undefined;
|
|
202
204
|
} | undefined;
|
|
205
|
+
plugins?: (string | [string, Record<string, unknown>])[] | undefined;
|
|
203
206
|
customCss?: string[] | undefined;
|
|
204
207
|
}>;
|
|
205
208
|
type BarodocConfigInput = z.input<typeof barodocConfigSchema>;
|
package/dist/config/index.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
barodocConfigSchema,
|
|
3
|
-
loadConfig
|
|
4
|
-
} from "./chunk-JQRBNHRZ.js";
|
|
5
1
|
import {
|
|
6
2
|
getLocaleFromPath,
|
|
7
3
|
getLocaleLabel,
|
|
@@ -16,6 +12,10 @@ import {
|
|
|
16
12
|
runConfigHook,
|
|
17
13
|
runHook
|
|
18
14
|
} from "./chunk-UICDSNBG.js";
|
|
15
|
+
import {
|
|
16
|
+
barodocConfigSchema,
|
|
17
|
+
loadConfig
|
|
18
|
+
} from "./chunk-UNDAI47C.js";
|
|
19
19
|
|
|
20
20
|
// src/integration.ts
|
|
21
21
|
var VIRTUAL_CONFIG_ID = "virtual:barodoc/config";
|
|
@@ -56,22 +56,41 @@ function barodoc(options) {
|
|
|
56
56
|
"astro:config:setup": async ({
|
|
57
57
|
config,
|
|
58
58
|
updateConfig,
|
|
59
|
-
logger
|
|
59
|
+
logger,
|
|
60
|
+
command
|
|
60
61
|
}) => {
|
|
61
62
|
logger.info("Loading Barodoc configuration...");
|
|
62
63
|
const rootPath = config.root instanceof URL ? config.root.pathname : String(config.root);
|
|
63
64
|
resolvedConfig = await loadConfig(configPath, rootPath);
|
|
64
65
|
logger.info(`Loaded config: ${resolvedConfig.name}`);
|
|
66
|
+
const mode = command === "dev" ? "development" : "production";
|
|
67
|
+
const pluginContext = {
|
|
68
|
+
config: resolvedConfig,
|
|
69
|
+
root: rootPath,
|
|
70
|
+
mode
|
|
71
|
+
};
|
|
72
|
+
const pluginConfigs = resolvedConfig.plugins ?? [];
|
|
73
|
+
const plugins = await loadPlugins(pluginConfigs, pluginContext);
|
|
74
|
+
resolvedConfig = await runConfigHook(
|
|
75
|
+
plugins,
|
|
76
|
+
resolvedConfig,
|
|
77
|
+
pluginContext
|
|
78
|
+
);
|
|
79
|
+
pluginContext.config = resolvedConfig;
|
|
80
|
+
if (plugins.length > 0) {
|
|
81
|
+
logger.info(`Loaded ${plugins.length} plugin(s)`);
|
|
82
|
+
}
|
|
65
83
|
const i18nConfig = resolvedConfig.i18n || {
|
|
66
84
|
defaultLocale: "en",
|
|
67
85
|
locales: ["en"]
|
|
68
86
|
};
|
|
69
87
|
const themeIntegration = options.theme.integration();
|
|
88
|
+
const pluginIntegrations = getPluginIntegrations(plugins, pluginContext);
|
|
70
89
|
updateConfig({
|
|
71
90
|
vite: {
|
|
72
91
|
plugins: [createVirtualModulesPlugin(resolvedConfig)]
|
|
73
92
|
},
|
|
74
|
-
integrations: [themeIntegration]
|
|
93
|
+
integrations: [themeIntegration, ...pluginIntegrations]
|
|
75
94
|
});
|
|
76
95
|
logger.info(
|
|
77
96
|
`i18n configured: ${i18nConfig.locales.length} locale(s)`
|