@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.cjs
CHANGED
|
@@ -19665,14 +19665,36 @@ var SwellTheme3 = class {
|
|
|
19665
19665
|
"layouts",
|
|
19666
19666
|
name
|
|
19667
19667
|
);
|
|
19668
|
-
if (templateConfig) {
|
|
19669
|
-
|
|
19670
|
-
templateConfig.file_path,
|
|
19671
|
-
data
|
|
19672
|
-
);
|
|
19673
|
-
return typeof content === "string" ? content : `<!-- invalid layout: ${name}--> {{ content_for_layout }}`;
|
|
19668
|
+
if (!templateConfig) {
|
|
19669
|
+
throw new Error(`Layout template not found: ${name}`);
|
|
19674
19670
|
}
|
|
19675
|
-
|
|
19671
|
+
let content = await this.renderThemeTemplate(
|
|
19672
|
+
templateConfig.file_path,
|
|
19673
|
+
data
|
|
19674
|
+
);
|
|
19675
|
+
if (typeof content !== "string") {
|
|
19676
|
+
return `<!-- invalid layout: ${name}--> {{ content_for_layout }}`;
|
|
19677
|
+
}
|
|
19678
|
+
if (!this.globals.request.is_editor) {
|
|
19679
|
+
let customCss = this.globals.settings.custom_css || "";
|
|
19680
|
+
if (Array.isArray(customCss)) {
|
|
19681
|
+
customCss = customCss.join("\n").trim();
|
|
19682
|
+
}
|
|
19683
|
+
if (customCss) {
|
|
19684
|
+
let pos = -1;
|
|
19685
|
+
let match = null;
|
|
19686
|
+
const regex = /<\/body\s*?>/gi;
|
|
19687
|
+
while ((match = regex.exec(content)) !== null) {
|
|
19688
|
+
pos = match.index;
|
|
19689
|
+
}
|
|
19690
|
+
if (pos !== -1) {
|
|
19691
|
+
content = `${content.slice(0, pos)}
|
|
19692
|
+
<style>${customCss}</style>
|
|
19693
|
+
${content.slice(pos)}`;
|
|
19694
|
+
}
|
|
19695
|
+
}
|
|
19696
|
+
}
|
|
19697
|
+
return content;
|
|
19676
19698
|
}
|
|
19677
19699
|
async renderPageTemplate(name, data, altTemplateId) {
|
|
19678
19700
|
let templateConfig = null;
|