@decocms/blocks 7.79.8 → 7.80.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/package.json
CHANGED
|
@@ -149,6 +149,7 @@ function sectionGlobKey(
|
|
|
149
149
|
sectionKey: string,
|
|
150
150
|
glob: Record<string, () => Promise<any>>,
|
|
151
151
|
): string | null {
|
|
152
|
+
if (glob[sectionKey]) return sectionKey; // already a CMS key (package sections)
|
|
152
153
|
const relative = sectionKey.replace("site/sections/", "./sections/");
|
|
153
154
|
if (glob[relative]) return relative;
|
|
154
155
|
const withDot = sectionKey.replace("site/", "./");
|
package/src/setup.ts
CHANGED
|
@@ -30,6 +30,8 @@ export interface SiteSetupOptions {
|
|
|
30
30
|
/**
|
|
31
31
|
* Section glob from Vite — pass `import.meta.glob("./sections/**\/*.tsx")`.
|
|
32
32
|
* Keys are transformed from `./sections/X.tsx` → `site/sections/X.tsx`.
|
|
33
|
+
* Keys not starting with `./` are already CMS keys (e.g. `packageSectionImports`
|
|
34
|
+
* from sections.gen.ts, `ui/sections/X.tsx`) and are registered as-is.
|
|
33
35
|
*/
|
|
34
36
|
sections: Record<string, () => Promise<any>>;
|
|
35
37
|
|
|
@@ -85,7 +87,7 @@ export function createSiteSetup(options: SiteSetupOptions): void {
|
|
|
85
87
|
// 2. Section glob registration — transform Vite paths to CMS keys
|
|
86
88
|
const sections: Record<string, () => Promise<any>> = {};
|
|
87
89
|
for (const [path, loader] of Object.entries(options.sections)) {
|
|
88
|
-
sections[`site/${path.slice(2)}`] = loader;
|
|
90
|
+
sections[path.startsWith("./") ? `site/${path.slice(2)}` : path] = loader;
|
|
89
91
|
}
|
|
90
92
|
registerSections(sections);
|
|
91
93
|
|