@skafform/vite-plugin 0.1.1 → 0.1.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.js +0 -28
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7,8 +7,6 @@ var VIRTUAL_CONFIG = "virtual:skafform/config";
|
|
|
7
7
|
var RESOLVED_CONFIG = "\0virtual:skafform/config";
|
|
8
8
|
var VIRTUAL_SERVER_INIT = "virtual:skafform/server-init";
|
|
9
9
|
var RESOLVED_SERVER_INIT = "\0virtual:skafform/server-init";
|
|
10
|
-
var VIRTUAL_NAV = "virtual:skafform/nav";
|
|
11
|
-
var RESOLVED_NAV = "\0virtual:skafform/nav";
|
|
12
10
|
var VIRTUAL_ADMIN_SECTIONS = "virtual:skafform/admin-sections";
|
|
13
11
|
var RESOLVED_ADMIN_SECTIONS = "\0virtual:skafform/admin-sections";
|
|
14
12
|
var norm = (p) => p.replace(/\\/g, "/");
|
|
@@ -95,7 +93,6 @@ ${vars}
|
|
|
95
93
|
resolveId(id, importer) {
|
|
96
94
|
if (id === VIRTUAL_CONFIG) return RESOLVED_CONFIG;
|
|
97
95
|
if (id === VIRTUAL_SERVER_INIT) return RESOLVED_SERVER_INIT;
|
|
98
|
-
if (id === VIRTUAL_NAV) return RESOLVED_NAV;
|
|
99
96
|
if (id === VIRTUAL_ADMIN_SECTIONS) return RESOLVED_ADMIN_SECTIONS;
|
|
100
97
|
if (id.startsWith(".") && importer) {
|
|
101
98
|
const themeDir = norm(resolve(root, `themes/${config.theme}`));
|
|
@@ -123,31 +120,6 @@ ${vars}
|
|
|
123
120
|
customize: { ...themeJson.customize ?? {}, ...config.customize ?? {} }
|
|
124
121
|
})}`;
|
|
125
122
|
}
|
|
126
|
-
if (id === RESOLVED_NAV) {
|
|
127
|
-
const bricksConfigPath = resolve(root, "skafform-bricks.json");
|
|
128
|
-
const themeJson = getThemeJson(config.theme);
|
|
129
|
-
const navLocations = themeJson.nav_locations ?? config.nav_locations ?? {};
|
|
130
|
-
const customNav = themeJson.nav ?? config.nav ?? {};
|
|
131
|
-
const bricksConfig = existsSync(bricksConfigPath) ? JSON.parse(readFileSync(bricksConfigPath, "utf-8")) : { bricks: {} };
|
|
132
|
-
const registry = {};
|
|
133
|
-
for (const loc of Object.keys(navLocations)) registry[loc] = [];
|
|
134
|
-
for (const [brickName, brick] of Object.entries(bricksConfig.bricks ?? {})) {
|
|
135
|
-
for (const item of brick.nav ?? []) {
|
|
136
|
-
if (registry[item.location] !== void 0) {
|
|
137
|
-
registry[item.location].push({ ...item, order: item.order ?? 0, brick: brickName });
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
for (const [loc, items] of Object.entries(customNav)) {
|
|
142
|
-
if (registry[loc] !== void 0) {
|
|
143
|
-
registry[loc].push(...items.map((i) => ({ ...i, order: i.order ?? 0, brick: "config" })));
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
for (const loc of Object.keys(registry)) {
|
|
147
|
-
registry[loc].sort((a, b) => a.order - b.order);
|
|
148
|
-
}
|
|
149
|
-
return `export default ${JSON.stringify(registry)}`;
|
|
150
|
-
}
|
|
151
123
|
if (id === RESOLVED_ADMIN_SECTIONS) {
|
|
152
124
|
const bricksConfigPath = resolve(root, "skafform-bricks.json");
|
|
153
125
|
if (!existsSync(bricksConfigPath)) return "export default []";
|