@skafform/vite-plugin 0.1.0 → 0.1.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.js CHANGED
@@ -9,6 +9,8 @@ var VIRTUAL_SERVER_INIT = "virtual:skafform/server-init";
9
9
  var RESOLVED_SERVER_INIT = "\0virtual:skafform/server-init";
10
10
  var VIRTUAL_NAV = "virtual:skafform/nav";
11
11
  var RESOLVED_NAV = "\0virtual:skafform/nav";
12
+ var VIRTUAL_ADMIN_SECTIONS = "virtual:skafform/admin-sections";
13
+ var RESOLVED_ADMIN_SECTIONS = "\0virtual:skafform/admin-sections";
12
14
  var norm = (p) => p.replace(/\\/g, "/");
13
15
  function loadBrickIndex(root) {
14
16
  const bricksDir = resolve(root, "bricks");
@@ -94,6 +96,7 @@ ${vars}
94
96
  if (id === VIRTUAL_CONFIG) return RESOLVED_CONFIG;
95
97
  if (id === VIRTUAL_SERVER_INIT) return RESOLVED_SERVER_INIT;
96
98
  if (id === VIRTUAL_NAV) return RESOLVED_NAV;
99
+ if (id === VIRTUAL_ADMIN_SECTIONS) return RESOLVED_ADMIN_SECTIONS;
97
100
  if (id.startsWith(".") && importer) {
98
101
  const themeDir = norm(resolve(root, `themes/${config.theme}`));
99
102
  const componentsDir = themeDir + "/components";
@@ -145,6 +148,18 @@ ${vars}
145
148
  }
146
149
  return `export default ${JSON.stringify(registry)}`;
147
150
  }
151
+ if (id === RESOLVED_ADMIN_SECTIONS) {
152
+ const bricksConfigPath = resolve(root, "skafform-bricks.json");
153
+ if (!existsSync(bricksConfigPath)) return "export default []";
154
+ const bricksConfig = JSON.parse(readFileSync(bricksConfigPath, "utf-8"));
155
+ const sections = [];
156
+ for (const brick of Object.values(bricksConfig.bricks ?? {})) {
157
+ for (const section of brick.adminSections ?? []) {
158
+ sections.push(section);
159
+ }
160
+ }
161
+ return `export default ${JSON.stringify(sections)}`;
162
+ }
148
163
  if (id === RESOLVED_SERVER_INIT) {
149
164
  const bricksConfigPath = resolve(root, "skafform-bricks.json");
150
165
  if (!existsSync(bricksConfigPath)) return "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skafform/vite-plugin",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
package/types.d.ts CHANGED
@@ -18,3 +18,14 @@ declare module "virtual:skafform/config" {
18
18
  export default config
19
19
  }
20
20
 
21
+ interface SkafformAdminSection {
22
+ label: string
23
+ href: string
24
+ file: string
25
+ }
26
+
27
+ declare module "virtual:skafform/admin-sections" {
28
+ const sections: SkafformAdminSection[]
29
+ export default sections
30
+ }
31
+