soinproduction-gutenberg 0.1.8 → 0.1.9
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.
|
@@ -9,6 +9,7 @@ import breakpoints from './breakpoints.cjs';
|
|
|
9
9
|
import remDimensions from './rem-css.cjs';
|
|
10
10
|
import { scopeEditorSelector } from './editor-css.mjs';
|
|
11
11
|
import { syncSections } from './sync-sections.mjs';
|
|
12
|
+
import {publishSectionPreviews} from './section-previews.mjs';
|
|
12
13
|
import {syncBlocks} from './sync-blocks.mjs';
|
|
13
14
|
import * as react from 'react';
|
|
14
15
|
import * as reactDom from 'react-dom';
|
|
@@ -127,16 +128,8 @@ for (const group of ['sections', 'elements', 'layout']) {
|
|
|
127
128
|
|
|
128
129
|
if(connections.modules.includes('booking'))await import('./build-booking.mjs');
|
|
129
130
|
|
|
130
|
-
//
|
|
131
|
-
|
|
132
|
-
if (!entry.isDirectory()) continue;
|
|
133
|
-
for (const extension of ['webp', 'png', 'jpg', 'jpeg', 'svg']) {
|
|
134
|
-
const source = `src/sections/${entry.name}/preview.${extension}`;
|
|
135
|
-
if (!fs.existsSync(source)) continue;
|
|
136
|
-
fs.mkdirSync(output + '/previews/sections', { recursive: true });
|
|
137
|
-
fs.copyFileSync(source, `${output}/previews/sections/${entry.name}.${extension}`);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
131
|
+
// Publish each section preview under the stable metadata slug and its legacy folder alias.
|
|
132
|
+
publishSectionPreviews(process.cwd(),path.resolve(output));
|
|
140
133
|
|
|
141
134
|
// Editor-only CSS uses the same named media queries as authored content.
|
|
142
135
|
const editorCssPath=output+'/editor.css';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
/** Publish the metadata slug used by section(), retaining folder URLs as compatibility aliases. */
|
|
5
|
+
export function publishSectionPreviews(root, output) {
|
|
6
|
+
const directory=path.join(root,'src/sections');if(!fs.existsSync(directory))return [];
|
|
7
|
+
const published=[];
|
|
8
|
+
for(const entry of fs.readdirSync(directory,{withFileTypes:true})){
|
|
9
|
+
if(!entry.isDirectory()||!entry.name.startsWith('section-'))continue;
|
|
10
|
+
const folder=path.join(directory,entry.name),metaFile=path.join(folder,'section.json');
|
|
11
|
+
const meta=fs.existsSync(metaFile)?JSON.parse(fs.readFileSync(metaFile,'utf8')):{};
|
|
12
|
+
const slug=meta.slug??entry.name;
|
|
13
|
+
if(!/^[a-z0-9][a-z0-9-]*$/.test(slug))throw new Error('Invalid section preview slug: '+slug);
|
|
14
|
+
for(const extension of ['webp','png','jpg','jpeg','svg']){
|
|
15
|
+
const source=path.join(folder,'preview.'+extension);if(!fs.existsSync(source))continue;
|
|
16
|
+
const target=path.join(output,'previews/sections');fs.mkdirSync(target,{recursive:true});
|
|
17
|
+
for(const name of new Set([slug,entry.name])){
|
|
18
|
+
const file=path.join(target,name+'.'+extension);fs.copyFileSync(source,file);published.push(file);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return published;
|
|
23
|
+
}
|
package/package.json
CHANGED
package/tooling/build-editor.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import breakpoints from './breakpoints.cjs';
|
|
|
9
9
|
import remDimensions from './rem-css.cjs';
|
|
10
10
|
import { scopeEditorSelector } from './editor-css.mjs';
|
|
11
11
|
import { syncSections } from './sync-sections.mjs';
|
|
12
|
+
import {publishSectionPreviews} from './section-previews.mjs';
|
|
12
13
|
import {syncBlocks} from './sync-blocks.mjs';
|
|
13
14
|
import * as react from 'react';
|
|
14
15
|
import * as reactDom from 'react-dom';
|
|
@@ -127,16 +128,8 @@ for (const group of ['sections', 'elements', 'layout']) {
|
|
|
127
128
|
|
|
128
129
|
if(connections.modules.includes('booking'))await import('./build-booking.mjs');
|
|
129
130
|
|
|
130
|
-
//
|
|
131
|
-
|
|
132
|
-
if (!entry.isDirectory()) continue;
|
|
133
|
-
for (const extension of ['webp', 'png', 'jpg', 'jpeg', 'svg']) {
|
|
134
|
-
const source = `src/sections/${entry.name}/preview.${extension}`;
|
|
135
|
-
if (!fs.existsSync(source)) continue;
|
|
136
|
-
fs.mkdirSync(output + '/previews/sections', { recursive: true });
|
|
137
|
-
fs.copyFileSync(source, `${output}/previews/sections/${entry.name}.${extension}`);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
131
|
+
// Publish each section preview under the stable metadata slug and its legacy folder alias.
|
|
132
|
+
publishSectionPreviews(process.cwd(),path.resolve(output));
|
|
140
133
|
|
|
141
134
|
// Editor-only CSS uses the same named media queries as authored content.
|
|
142
135
|
const editorCssPath=output+'/editor.css';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
/** Publish the metadata slug used by section(), retaining folder URLs as compatibility aliases. */
|
|
5
|
+
export function publishSectionPreviews(root, output) {
|
|
6
|
+
const directory=path.join(root,'src/sections');if(!fs.existsSync(directory))return [];
|
|
7
|
+
const published=[];
|
|
8
|
+
for(const entry of fs.readdirSync(directory,{withFileTypes:true})){
|
|
9
|
+
if(!entry.isDirectory()||!entry.name.startsWith('section-'))continue;
|
|
10
|
+
const folder=path.join(directory,entry.name),metaFile=path.join(folder,'section.json');
|
|
11
|
+
const meta=fs.existsSync(metaFile)?JSON.parse(fs.readFileSync(metaFile,'utf8')):{};
|
|
12
|
+
const slug=meta.slug??entry.name;
|
|
13
|
+
if(!/^[a-z0-9][a-z0-9-]*$/.test(slug))throw new Error('Invalid section preview slug: '+slug);
|
|
14
|
+
for(const extension of ['webp','png','jpg','jpeg','svg']){
|
|
15
|
+
const source=path.join(folder,'preview.'+extension);if(!fs.existsSync(source))continue;
|
|
16
|
+
const target=path.join(output,'previews/sections');fs.mkdirSync(target,{recursive:true});
|
|
17
|
+
for(const name of new Set([slug,entry.name])){
|
|
18
|
+
const file=path.join(target,name+'.'+extension);fs.copyFileSync(source,file);published.push(file);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return published;
|
|
23
|
+
}
|