@swell/apps-sdk 1.0.126 → 1.0.127
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.cjs +29 -7
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +29 -7
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +29 -7
- package/dist/index.mjs.map +2 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -19542,14 +19542,36 @@ var SwellTheme3 = class {
|
|
|
19542
19542
|
"layouts",
|
|
19543
19543
|
name
|
|
19544
19544
|
);
|
|
19545
|
-
if (templateConfig) {
|
|
19546
|
-
|
|
19547
|
-
templateConfig.file_path,
|
|
19548
|
-
data
|
|
19549
|
-
);
|
|
19550
|
-
return typeof content === "string" ? content : `<!-- invalid layout: ${name}--> {{ content_for_layout }}`;
|
|
19545
|
+
if (!templateConfig) {
|
|
19546
|
+
throw new Error(`Layout template not found: ${name}`);
|
|
19551
19547
|
}
|
|
19552
|
-
|
|
19548
|
+
let content = await this.renderThemeTemplate(
|
|
19549
|
+
templateConfig.file_path,
|
|
19550
|
+
data
|
|
19551
|
+
);
|
|
19552
|
+
if (typeof content !== "string") {
|
|
19553
|
+
return `<!-- invalid layout: ${name}--> {{ content_for_layout }}`;
|
|
19554
|
+
}
|
|
19555
|
+
if (!this.globals.request.is_editor) {
|
|
19556
|
+
let customCss = this.globals.settings.custom_css || "";
|
|
19557
|
+
if (Array.isArray(customCss)) {
|
|
19558
|
+
customCss = customCss.join("\n").trim();
|
|
19559
|
+
}
|
|
19560
|
+
if (customCss) {
|
|
19561
|
+
let pos = -1;
|
|
19562
|
+
let match = null;
|
|
19563
|
+
const regex = /<\/body\s*?>/gi;
|
|
19564
|
+
while ((match = regex.exec(content)) !== null) {
|
|
19565
|
+
pos = match.index;
|
|
19566
|
+
}
|
|
19567
|
+
if (pos !== -1) {
|
|
19568
|
+
content = `${content.slice(0, pos)}
|
|
19569
|
+
<style>${customCss}</style>
|
|
19570
|
+
${content.slice(pos)}`;
|
|
19571
|
+
}
|
|
19572
|
+
}
|
|
19573
|
+
}
|
|
19574
|
+
return content;
|
|
19553
19575
|
}
|
|
19554
19576
|
async renderPageTemplate(name, data, altTemplateId) {
|
|
19555
19577
|
let templateConfig = null;
|