domma-cms 0.6.4 → 0.6.5
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
|
@@ -64,7 +64,7 @@ async function loadBlockTemplate(blockName) {
|
|
|
64
64
|
* @param {object|null} ctaOpts - Optional CTA button options
|
|
65
65
|
* @returns {string}
|
|
66
66
|
*/
|
|
67
|
-
function renderCollectionBlocks(entries, blockTemplate, emptyMsg, ctaOpts) {
|
|
67
|
+
function renderCollectionBlocks(entries, blockTemplate, emptyMsg, ctaOpts, cols) {
|
|
68
68
|
if (!entries.length) {
|
|
69
69
|
return `<div class="dm-collection-display dm-collection-empty"><p>${escapeHtmlText(emptyMsg)}</p></div>`;
|
|
70
70
|
}
|
|
@@ -88,7 +88,12 @@ function renderCollectionBlocks(entries, blockTemplate, emptyMsg, ctaOpts) {
|
|
|
88
88
|
return html;
|
|
89
89
|
});
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
const validCols = ['2', '3', '4', '5', '6'].includes(String(cols)) ? cols : '';
|
|
92
|
+
const wrapperClass = validCols
|
|
93
|
+
? `dm-collection-display dm-collection-blocks grid grid-cols-${validCols} gap-4`
|
|
94
|
+
: 'dm-collection-display dm-collection-blocks';
|
|
95
|
+
|
|
96
|
+
return `<div class="${wrapperClass}">\n${items.join('\n')}\n</div>`;
|
|
92
97
|
}
|
|
93
98
|
|
|
94
99
|
function renderCollectionTable(slug, entries, visibleFields, attrs, ctaOpts) {
|
|
@@ -333,7 +338,8 @@ async function processCollectionBlocks(markdown) {
|
|
|
333
338
|
if (blockName) {
|
|
334
339
|
try {
|
|
335
340
|
const tpl = await loadBlockTemplate(blockName);
|
|
336
|
-
|
|
341
|
+
const cols = attrs.cols || '';
|
|
342
|
+
replacement = renderCollectionBlocks(entries, tpl, emptyMsg, ctaOpts, cols);
|
|
337
343
|
} catch {
|
|
338
344
|
replacement = `<div class="dm-collection-display dm-collection-empty"><p>Block template “${escapeHtmlText(blockName)}” not found.</p></div>`;
|
|
339
345
|
}
|