domma-cms 1.31.0 → 1.33.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/CHANGELOG.md +15 -0
- package/CLAUDE.md +20 -2
- package/admin/js/lib/admin-brand.js +1 -1
- package/admin/js/lib/admin-theme.js +1 -1
- package/admin/js/lib/block-packs.js +26 -0
- package/admin/js/lib/block-tags.js +6 -1
- package/admin/js/lib/shortcode-context-menu.js +2 -2
- package/admin/js/lib/shortcode-form.js +7 -4
- package/admin/js/lib/shortcode-registry.js +1 -1
- package/admin/js/lib/sidebar-frequent.js +1 -1
- package/admin/js/lib/sidebar-renderer.js +4 -4
- package/admin/js/lib/site-settings-arrange.js +2 -2
- package/admin/js/lib/theme-aware-logo.js +1 -0
- package/admin/js/templates/docs/usage-blocks.html +28 -1
- package/admin/js/templates/settings.html +7 -1
- package/admin/js/views/blocks.js +4 -4
- package/admin/js/views/settings.js +2 -2
- package/docs/DommaFeatures.md +87 -8
- package/docs/markdown-shortcodes.md +35 -1
- package/docs/starter-blocks.md +106 -1
- package/package.json +1 -1
- package/server/blocks/catalog.json +30 -0
- package/server/blocks/domma-block-comparison-card.css +20 -0
- package/server/blocks/domma-block-comparison-card.html +18 -0
- package/server/blocks/domma-block-comparison-card.meta.json +7 -0
- package/server/blocks/domma-block-cta-card.css +20 -0
- package/server/blocks/domma-block-cta-card.html +15 -0
- package/server/blocks/domma-block-cta-card.meta.json +7 -0
- package/server/blocks/domma-block-cushion-card.css +30 -0
- package/server/blocks/domma-block-cushion-card.html +11 -0
- package/server/blocks/domma-block-cushion-card.meta.json +7 -0
- package/server/blocks/domma-block-feature-card.css +20 -0
- package/server/blocks/domma-block-feature-card.html +15 -0
- package/server/blocks/domma-block-feature-card.meta.json +7 -0
- package/server/blocks/domma-block-image-card.css +20 -0
- package/server/blocks/domma-block-image-card.html +17 -0
- package/server/blocks/domma-block-image-card.meta.json +7 -0
- package/server/routes/api/block-packs.js +55 -0
- package/server/routes/api/blocks.js +4 -1
- package/server/services/adminBrand.js +4 -1
- package/server/services/block-pack-assets.js +6 -0
- package/server/services/block-packs.js +291 -0
- package/server/services/block-slots.js +43 -0
- package/server/services/block-write-lock.js +44 -0
- package/server/services/blocks.js +18 -3
- package/server/services/embedCsp.js +1 -1
- package/server/services/markdown.js +166 -14
- package/server/services/sidebarFrequent.js +1 -1
- package/server/services/starter-block-packs.js +22 -0
|
@@ -9,6 +9,8 @@ import {marked} from 'marked';
|
|
|
9
9
|
import sanitizeHtml from 'sanitize-html';
|
|
10
10
|
import {readdir, readFile} from 'fs/promises';
|
|
11
11
|
import {AsyncLocalStorage} from 'node:async_hooks';
|
|
12
|
+
import {randomUUID} from 'node:crypto';
|
|
13
|
+
import {blockSlots, pairedRanges, slotBodies, SLOT_PATTERN} from './block-slots.js';
|
|
12
14
|
import path from 'path';
|
|
13
15
|
import {fileURLToPath} from 'url';
|
|
14
16
|
import {applyTransforms, getSanitizeExtensions, getShortcodeProcessors} from './hooks.js';
|
|
@@ -37,7 +39,7 @@ const BLOCKS_DIR = path.resolve(__dirname_md, '../../content/blocks');
|
|
|
37
39
|
export const BUILTIN_SHORTCODES = new Set([
|
|
38
40
|
'block', 'collection', 'view', 'dconfig', 'component', 'tabs', 'tab',
|
|
39
41
|
'accordion', 'item', 'carousel', 'slide', 'countdown', 'timeline',
|
|
40
|
-
'event', 'listgroup', 'spacer', 'center', 'icon', 'demo', 'embed', 'image', 'form', 'hero', 'table', 'badge',
|
|
42
|
+
'event', 'listgroup', 'spacer', 'center', 'icon', 'demo', 'embed', 'map', 'image', 'form', 'hero', 'table', 'badge',
|
|
41
43
|
'text', 'button', 'link', 'cta', 'grid', 'row', 'col', 'card', 'box',
|
|
42
44
|
'banner', 'slideover', 'menu',
|
|
43
45
|
// effects
|
|
@@ -527,10 +529,10 @@ function renderCollectionBlocks(entries, blockTemplate, emptyMsg, ctaOpts, cols,
|
|
|
527
529
|
return `${styleTag}<div class="${wrapperClass}"${ctx}>\n${items.join('\n')}\n</div>`;
|
|
528
530
|
}
|
|
529
531
|
|
|
530
|
-
function
|
|
532
|
+
function fillBlockAttrs(tmpl, attrs) {
|
|
531
533
|
// Triple-brace raw pass-through and `{{field}}` (optional `:format`, e.g. `{{date:DD MMM YYYY}}`)
|
|
532
534
|
// in one pass, so a raw value is never read again for placeholders.
|
|
533
|
-
|
|
535
|
+
return fillTemplateLines(tmpl, (_, rawKey, key, fmt) => {
|
|
534
536
|
if (rawKey !== undefined) return String(attrs[rawKey] ?? '');
|
|
535
537
|
const raw = attrs[key] ?? '';
|
|
536
538
|
if (fmt) {
|
|
@@ -539,16 +541,100 @@ function renderBlockFromAttrs(tmpl, attrs, blockName = '') {
|
|
|
539
541
|
}
|
|
540
542
|
return escapeHtmlText(raw);
|
|
541
543
|
});
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
function renderBlockFromAttrs(tmpl, attrs, blockName = '') {
|
|
547
|
+
const rendered = fillBlockAttrs(tmpl, attrs);
|
|
542
548
|
const extraClass = attrs.class ? ` ${escapeAttr(attrs.class)}` : '';
|
|
543
549
|
const idAttr = attrs.id ? ` id="${escapeAttr(attrs.id)}"` : '';
|
|
544
550
|
const dataBlockAttr = blockName ? ` data-block="${escapeAttr(blockName)}"` : '';
|
|
545
551
|
return `<div class="dm-static-block${extraClass}"${idAttr}${dataBlockAttr}>${rendered}</div>`;
|
|
546
552
|
}
|
|
547
553
|
|
|
554
|
+
// Rich slot content is rendered once, then restored after the outer shortcode pipeline.
|
|
555
|
+
// This prevents code examples and entry data inside a slot from becoming live tags again.
|
|
556
|
+
const SLOT_DEPTH = Symbol('block slot depth');
|
|
557
|
+
const SLOT_BUDGET = Symbol('block slot budget');
|
|
558
|
+
const SLOT_FRAGMENT = Symbol('block slot fragment');
|
|
559
|
+
async function processSlottedBlocks(content, opts, tagSet, flags, usedComponents) {
|
|
560
|
+
const safe = scrubCodeRegions(content, true);
|
|
561
|
+
const names = new Set(['block', ...await getBlockShortTagNames()]);
|
|
562
|
+
const protectedHtml = new Map();
|
|
563
|
+
const nonce = randomUUID();
|
|
564
|
+
const hold = html => {
|
|
565
|
+
const token = `<!--dm-slot-${nonce}-${protectedHtml.size}-->`;
|
|
566
|
+
protectedHtml.set(token, html);
|
|
567
|
+
return token;
|
|
568
|
+
};
|
|
569
|
+
// Paired tags can be nested under tags with the same name. Self-closing slot
|
|
570
|
+
// templates are included too, so their fallback content gets the same renderer.
|
|
571
|
+
const ranges = pairedRanges(safe.scrubbed, names);
|
|
572
|
+
const singles = /\[([a-z][\w-]*)(?=[\s/\]])((?:"[^"]*"|'[^']*'|[^\]"'])*?)\/\]/g;
|
|
573
|
+
for (const m of safe.scrubbed.matchAll(singles)) {
|
|
574
|
+
if (!names.has(m[1]) || ranges.some(r => m.index >= r.start && m.index < r.end)) continue;
|
|
575
|
+
ranges.push({name:m[1], attrs:m[2], start:m.index, end:m.index+m[0].length, self:true});
|
|
576
|
+
}
|
|
577
|
+
let output = safe.scrubbed;
|
|
578
|
+
const innerRestores = [];
|
|
579
|
+
// A paired call whose body is not slot content (no such block, or a block without slots) keeps its body as page
|
|
580
|
+
// content - its own paired calls expanded - so nothing is dropped and no later [block .../] pattern eats into it.
|
|
581
|
+
const keepBody = async (range, head = '') => {
|
|
582
|
+
const inner = await processSlottedBlocks(safe.restore(safe.scrubbed.slice(range.bodyStart, range.bodyEnd)), opts, tagSet, flags, usedComponents);
|
|
583
|
+
innerRestores.push(inner.restore);
|
|
584
|
+
output = output.slice(0, range.start) + head + inner.output + output.slice(range.end);
|
|
585
|
+
};
|
|
586
|
+
for (const range of ranges.sort((a,b) => b.start-a.start)) {
|
|
587
|
+
const attrs = parseShortcodeAttrs(range.attrs);
|
|
588
|
+
const name = range.name === 'block' ? attrs.template : range.name;
|
|
589
|
+
if (!name) { if (!range.self) await keepBody(range); continue; }
|
|
590
|
+
let template, css;
|
|
591
|
+
try { [template, css] = await Promise.all([loadBlockTemplate(name), loadBlockCss(name)]); }
|
|
592
|
+
catch { if (!range.self) await keepBody(range); continue; }
|
|
593
|
+
const hasSlots = blockSlots(template).length > 0;
|
|
594
|
+
if (range.self && !hasSlots) continue;
|
|
595
|
+
if (!hasSlots) { await keepBody(range, `[${range.name}${range.attrs.replace(/\s+$/, '')} /]`); continue; }
|
|
596
|
+
// Past the limits the block renders nothing (as a missing block does) rather than failing the whole page.
|
|
597
|
+
if (--opts[SLOT_BUDGET].remaining < 0 || (opts[SLOT_DEPTH] || 0) >= 24) {
|
|
598
|
+
output = output.slice(0, range.start) + output.slice(range.end);
|
|
599
|
+
continue;
|
|
600
|
+
}
|
|
601
|
+
tagSet.add(`block:${name}`);
|
|
602
|
+
const body = range.self ? '' : safe.scrubbed.slice(range.bodyStart, range.bodyEnd);
|
|
603
|
+
const bodies = slotBodies(body, names, parseShortcodeAttrs);
|
|
604
|
+
const renderedSlots = [];
|
|
605
|
+
// Protect declarations while parameters are filled, then fill each slot separately.
|
|
606
|
+
template = template.replace(SLOT_PATTERN, (_, slotName, fallback) => {
|
|
607
|
+
const key = slotName || 'default';
|
|
608
|
+
const token = `<!--dm-slot-source-${nonce}-${renderedSlots.length}-->`;
|
|
609
|
+
const source = bodies.has(key) ? safe.restore(bodies.get(key)) : fillBlockAttrs(applyTransforms('markdown:beforeParse', safe.restore(fallback)), attrs);
|
|
610
|
+
renderedSlots.push({token, source});
|
|
611
|
+
return token;
|
|
612
|
+
});
|
|
613
|
+
let html = buildBlockStyleTag(name, css) + renderBlockFromAttrs(template, attrs, name);
|
|
614
|
+
for (const slot of renderedSlots) {
|
|
615
|
+
// Prefix a blank line: slot text is a fragment, never YAML frontmatter.
|
|
616
|
+
const rendered = await parseMarkdown('\n' + slot.source, {...opts, [SLOT_DEPTH]:(opts[SLOT_DEPTH] || 0)+1, [SLOT_FRAGMENT]:true});
|
|
617
|
+
for (const tag of rendered.tags) tagSet.add(tag);
|
|
618
|
+
for (const component of rendered.usedComponents) usedComponents.add(component);
|
|
619
|
+
flags.perViewer ||= rendered.perViewer;
|
|
620
|
+
flags.hasExpiry ||= rendered.hasExpiry;
|
|
621
|
+
const held = hold(rendered.html);
|
|
622
|
+
html = html.replace(slot.token, () => held);
|
|
623
|
+
}
|
|
624
|
+
output = output.slice(0, range.start) + html + output.slice(range.end);
|
|
625
|
+
}
|
|
626
|
+
return {output:safe.restore(output), restore:html => {
|
|
627
|
+
// A function, never the string: "$&", "$$" and "$`" in slot content are text, not replacement patterns.
|
|
628
|
+
for (const [token, value] of protectedHtml) html = html.replaceAll(token, () => value);
|
|
629
|
+
for (const restore of innerRestores) html = restore(html);
|
|
630
|
+
return html;
|
|
631
|
+
}};
|
|
632
|
+
}
|
|
633
|
+
|
|
548
634
|
async function getBlockShortTagNames() {
|
|
549
635
|
try {
|
|
550
636
|
const files = await readdir(BLOCKS_DIR);
|
|
551
|
-
return files
|
|
637
|
+
return [...new Set([...files, ...[...(blockOverrides.getStore()?.keys() || [])].map(name => `${name}.html`)])]
|
|
552
638
|
.filter(f => f.endsWith('.html'))
|
|
553
639
|
.map(f => f.slice(0, -5))
|
|
554
640
|
.filter(name => /^[a-z0-9][a-z0-9-]*$/.test(name) && !BUILTIN_SHORTCODES.has(name));
|
|
@@ -566,6 +652,8 @@ async function getBlockShortTagNames() {
|
|
|
566
652
|
* @returns {Promise<string>}
|
|
567
653
|
*/
|
|
568
654
|
async function processStaticBlocks(content, tagSet) {
|
|
655
|
+
const safe = scrubCodeRegions(content, true);
|
|
656
|
+
content = safe.scrubbed;
|
|
569
657
|
// --- [block template="name" .../] ---
|
|
570
658
|
const pattern = /\[block\s+([\s\S]+?)\/\]/g;
|
|
571
659
|
const matches = [...content.matchAll(pattern)];
|
|
@@ -621,7 +709,7 @@ async function processStaticBlocks(content, tagSet) {
|
|
|
621
709
|
}
|
|
622
710
|
}
|
|
623
711
|
|
|
624
|
-
return output;
|
|
712
|
+
return safe.restore(output);
|
|
625
713
|
}
|
|
626
714
|
|
|
627
715
|
/**
|
|
@@ -2023,7 +2111,9 @@ async function processPluginShortcodes(markdown) {
|
|
|
2023
2111
|
|
|
2024
2112
|
const {scrubbed, restore} = scrubCodeRegions(markdown);
|
|
2025
2113
|
let result = scrubbed;
|
|
2026
|
-
|
|
2114
|
+
// renderMap tells a plugin with its own [map] (Blog Pro: OpenStreetMap by lat/lon) that the CMS has one too, so it can
|
|
2115
|
+
// hand back the tags it cannot draw (an address, a postcode) for processMapBlocks.
|
|
2116
|
+
const context = {parseShortcodeAttrs, scrubCodeRegions, marked, processCardBlocks, processGridBlocks, escapeAttr, renderMap};
|
|
2027
2117
|
|
|
2028
2118
|
async function replaceAsync(input, regex, mapMatch) {
|
|
2029
2119
|
const matches = [];
|
|
@@ -2047,13 +2137,14 @@ async function processPluginShortcodes(markdown) {
|
|
|
2047
2137
|
// Self-closing: [name attrs /]
|
|
2048
2138
|
result = await replaceAsync(
|
|
2049
2139
|
result,
|
|
2050
|
-
|
|
2140
|
+
// The name must end there: [map] is not [map-guess].
|
|
2141
|
+
new RegExp(`\\[${name}(?=[\\s/\\]])([^\\]]*)\\s*\\/\\]`, 'gi'),
|
|
2051
2142
|
(_, attrStr) => handler(attrStr, null, context)
|
|
2052
2143
|
);
|
|
2053
2144
|
// Wrapping: [name attrs]...[/name]
|
|
2054
2145
|
result = await replaceAsync(
|
|
2055
2146
|
result,
|
|
2056
|
-
new RegExp(`\\[${name}([^\\]]*)\\]([\\s\\S]*?)\\[\\/${name}\\]`, 'gi'),
|
|
2147
|
+
new RegExp(`\\[${name}(?=[\\s/\\]])([^\\]]*)\\]([\\s\\S]*?)\\[\\/${name}\\]`, 'gi'),
|
|
2057
2148
|
(_, attrStr, body) => handler(attrStr, body, context)
|
|
2058
2149
|
);
|
|
2059
2150
|
}
|
|
@@ -4397,6 +4488,61 @@ function processEmbedBlocks(markdown) {
|
|
|
4397
4488
|
));
|
|
4398
4489
|
}
|
|
4399
4490
|
|
|
4491
|
+
// ─── [map] - responsive Google Maps location embed ─────────────────────────
|
|
4492
|
+
|
|
4493
|
+
/** Build a safe map iframe from a location, postcode, or coordinate pin. */
|
|
4494
|
+
export function renderMap(attrs = {}) {
|
|
4495
|
+
const pin = typeof attrs.pin === 'string' ? attrs.pin.trim() : '';
|
|
4496
|
+
const lat = typeof attrs.lat === 'string' ? attrs.lat.trim() : '';
|
|
4497
|
+
const lonRaw = attrs.lon ?? attrs.lng;
|
|
4498
|
+
const lon = typeof lonRaw === 'string' ? lonRaw.trim() : '';
|
|
4499
|
+
const coordinates = pin || (lat && lon ? `${lat},${lon}` : '');
|
|
4500
|
+
const address = typeof attrs.address === 'string' ? attrs.address.trim() : '';
|
|
4501
|
+
const postcode = typeof attrs.postcode === 'string' ? attrs.postcode.trim() : '';
|
|
4502
|
+
const query = coordinates || address || postcode;
|
|
4503
|
+
if (!query || query.length > 500 || /[\u0000-\u001f]/.test(query)) {
|
|
4504
|
+
return _embedBlocked('Add a valid map pin, address, or postcode.');
|
|
4505
|
+
}
|
|
4506
|
+
if (coordinates && !/^[-+]?\d{1,3}(?:\.\d+)?\s*,\s*[-+]?\d{1,3}(?:\.\d+)?$/.test(coordinates)) {
|
|
4507
|
+
return _embedBlocked('Map pins must be latitude, longitude coordinates.');
|
|
4508
|
+
}
|
|
4509
|
+
if (coordinates) {
|
|
4510
|
+
const [latitude, longitude] = coordinates.split(',').map(Number);
|
|
4511
|
+
if (!Number.isFinite(latitude) || !Number.isFinite(longitude) || Math.abs(latitude) > 90 || Math.abs(longitude) > 180) {
|
|
4512
|
+
return _embedBlocked('Map pin coordinates are outside the valid range.');
|
|
4513
|
+
}
|
|
4514
|
+
}
|
|
4515
|
+
const parsedZoom = Number.parseInt(attrs.zoom, 10);
|
|
4516
|
+
const zoom = Number.isFinite(parsedZoom) ? Math.max(1, Math.min(20, parsedZoom)) : 14;
|
|
4517
|
+
// Use the direct embed endpoint. The /maps?q=... URL redirects here, and
|
|
4518
|
+
// Google marks that redirect SAMEORIGIN, which browsers can block in iframes.
|
|
4519
|
+
const encodedQuery = encodeURIComponent(query).replace(/%20/g, '+');
|
|
4520
|
+
const src = `https://www.google.com/maps/embed?origin=mfe&pb=!1m3!2m1!1s${encodedQuery}!6i${zoom}`;
|
|
4521
|
+
const ratio = _embedRatio(attrs.ratio);
|
|
4522
|
+
const titleText = String(attrs.title || address || postcode || 'Map');
|
|
4523
|
+
const title = escapeAttr(titleText);
|
|
4524
|
+
const styles = ['margin:1.5rem 0'];
|
|
4525
|
+
if (attrs.width) {
|
|
4526
|
+
const w = /^\d+%$/.test(attrs.width) ? attrs.width : `${parseInt(attrs.width, 10) || 0}px`;
|
|
4527
|
+
if (w !== '0px') styles.push(`max-width:${w}`);
|
|
4528
|
+
}
|
|
4529
|
+
const align = String(attrs.align || '').toLowerCase();
|
|
4530
|
+
if (align === 'center') styles.push('margin-left:auto', 'margin-right:auto');
|
|
4531
|
+
else if (align === 'right') styles.push('margin-left:auto');
|
|
4532
|
+
const caption = attrs.caption || attrs.title;
|
|
4533
|
+
return `<figure class="dm-map" style="${styles.join(';')}"><div class="dm-map-frame" style="position:relative;width:100%;aspect-ratio:${ratio}">`
|
|
4534
|
+
+ `<iframe src="${escapeAttr(src)}" title="${title}" loading="lazy" referrerpolicy="strict-origin-when-cross-origin"`
|
|
4535
|
+
+ ` style="position:absolute;inset:0;width:100%;height:100%;border:0" allowfullscreen></iframe></div>`
|
|
4536
|
+
+ (caption ? `<figcaption class="dm-embed-caption">${escapeAttr(caption)}</figcaption>` : '')
|
|
4537
|
+
+ '</figure>';
|
|
4538
|
+
}
|
|
4539
|
+
|
|
4540
|
+
function processMapBlocks(markdown) {
|
|
4541
|
+
const {scrubbed, restore} = scrubCodeRegions(markdown);
|
|
4542
|
+
return restore(scrubbed.replace(/\[map(?=[\s/\]])([^\]]*?)\/?\]/gi,
|
|
4543
|
+
(_, attrStr) => '\n' + renderMap(parseShortcodeAttrs(attrStr || '')) + '\n'));
|
|
4544
|
+
}
|
|
4545
|
+
|
|
4400
4546
|
// ─── [image] - a picture with options, optionally zoomable ─────────────────
|
|
4401
4547
|
|
|
4402
4548
|
const IMAGE_ALIGNS = ['left', 'center', 'right', 'float-left', 'float-right'];
|
|
@@ -5143,7 +5289,7 @@ export function sanitizePageHtml(html) {
|
|
|
5143
5289
|
// host allow-list).
|
|
5144
5290
|
allowedIframeHostnames: [
|
|
5145
5291
|
'www.youtube-nocookie.com', 'www.youtube.com', 'youtube.com',
|
|
5146
|
-
'player.vimeo.com',
|
|
5292
|
+
'player.vimeo.com', 'www.google.com',
|
|
5147
5293
|
...getEmbedAllowedHosts(),
|
|
5148
5294
|
],
|
|
5149
5295
|
// sanitize-html drops a RELATIVE iframe src whenever allowedIframeHostnames
|
|
@@ -5222,6 +5368,7 @@ export function sanitizePageHtml(html) {
|
|
|
5222
5368
|
* (a row-scoped `[view]`), so it must not share a role-keyed cache entry.
|
|
5223
5369
|
*/
|
|
5224
5370
|
export async function parseMarkdown(raw, opts = {}) {
|
|
5371
|
+
opts = {...opts, [SLOT_BUDGET]:opts[SLOT_BUDGET] || {remaining:500}};
|
|
5225
5372
|
const {data, content: written} = matter(raw);
|
|
5226
5373
|
const content = unindentShortTags(written);
|
|
5227
5374
|
|
|
@@ -5242,10 +5389,14 @@ export async function parseMarkdown(raw, opts = {}) {
|
|
|
5242
5389
|
const expiry = await applyShortcodeExpiry(expirySafe.scrubbed, {
|
|
5243
5390
|
...(opts.expiry || {}), urlPath: opts.urlPath || '/', parseAttrs: parseShortcodeAttrs
|
|
5244
5391
|
});
|
|
5245
|
-
const
|
|
5246
|
-
const
|
|
5392
|
+
const visible = expirySafe.restore(expiry.markdown);
|
|
5393
|
+
const preprocessed = opts[SLOT_FRAGMENT] ? visible : applyTransforms('markdown:beforeParse', visible);
|
|
5247
5394
|
const tagSet = new Set();
|
|
5248
5395
|
const flags = {perViewer: false, hasExpiry:expiry.hasExpiry};
|
|
5396
|
+
const slotComponents = new Set();
|
|
5397
|
+
const slots = await processSlottedBlocks(preprocessed, opts, tagSet, flags, slotComponents);
|
|
5398
|
+
const {output: withComponents, used: usedComponents} = collectAndRewriteComponents(slots.output);
|
|
5399
|
+
for (const component of slotComponents) usedComponents.add(component);
|
|
5249
5400
|
const withCollection = await processCollectionBlocks(withComponents, tagSet);
|
|
5250
5401
|
const withView = await processViewBlocks(withCollection, tagSet, opts.user || null, flags);
|
|
5251
5402
|
const withStaticBlock = await processStaticBlocks(withView, tagSet);
|
|
@@ -5268,7 +5419,8 @@ export async function parseMarkdown(raw, opts = {}) {
|
|
|
5268
5419
|
const withIcon = processIconBlocks(withCenter);
|
|
5269
5420
|
const withDemo = processDemoBlocks(withIcon);
|
|
5270
5421
|
const withEmbed = processImageBlocks(processEmbedBlocks(withDemo));
|
|
5271
|
-
const
|
|
5422
|
+
const withMap = processMapBlocks(withEmbed);
|
|
5423
|
+
const withForm = await processFormBlocks(withMap, tagSet);
|
|
5272
5424
|
const withHero = processHeroBlocks(withForm);
|
|
5273
5425
|
const withTable = processTableBlocks(withHero);
|
|
5274
5426
|
const withBadge = processBadgeBlocks(withTable);
|
|
@@ -5280,11 +5432,11 @@ export async function parseMarkdown(raw, opts = {}) {
|
|
|
5280
5432
|
const withCard = processCardBlocks(withGrid);
|
|
5281
5433
|
const withBanner = processBannerBlocks(withCard);
|
|
5282
5434
|
const withSlideover = processSlideoverBlocks(withBanner);
|
|
5283
|
-
const rendered = marked.parse(withSlideover);
|
|
5435
|
+
const rendered = slots.restore(marked.parse(withSlideover));
|
|
5284
5436
|
|
|
5285
5437
|
const sanitized = sanitizePageHtml(rendered);
|
|
5286
5438
|
|
|
5287
|
-
const html = applyTransforms('markdown:afterParse', sanitized);
|
|
5439
|
+
const html = opts[SLOT_FRAGMENT] ? sanitized : applyTransforms('markdown:afterParse', sanitized);
|
|
5288
5440
|
|
|
5289
5441
|
// Only emit component scripts for components that actually exist - missing
|
|
5290
5442
|
// references are already harmless (sanitiser strips the tag) but we also
|
|
@@ -13,7 +13,7 @@ import fs from 'fs/promises';
|
|
|
13
13
|
import path from 'path';
|
|
14
14
|
|
|
15
15
|
/** As FREQUENT_MAX in admin/js/lib/sidebar-frequent.js. */
|
|
16
|
-
export const FREQUENT_MAX =
|
|
16
|
+
export const FREQUENT_MAX = 16;
|
|
17
17
|
const URL_MAX = 500;
|
|
18
18
|
const USER_ID_RE = /^[A-Za-z0-9_-]{1,80}$/;
|
|
19
19
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** The bundled card pack follows the editable library; seeding never replaces a release. */
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
|
+
import {createBlockPackStore} from './block-packs.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A published version is immutable and every site builds this one from its own server/blocks files, so changing any
|
|
7
|
+
* of these files means a new version here (tests/services/block-packs.test.js holds the files' fingerprint per version).
|
|
8
|
+
*/
|
|
9
|
+
export const DOMMA_CARDS = {version:'1.0.1', names:['domma-block-cushion-card','domma-block-service-card','domma-block-pricing-card','domma-block-team-card','domma-block-testimonial']};
|
|
10
|
+
|
|
11
|
+
export async function seedStarterBlockPacks() {
|
|
12
|
+
const store=createBlockPackStore();
|
|
13
|
+
try { await store.published('domma-cards',DOMMA_CARDS.version);return; }
|
|
14
|
+
catch(error) {if(error.statusCode!==404)throw error;}
|
|
15
|
+
const names=DOMMA_CARDS.names;
|
|
16
|
+
const blocks=[];
|
|
17
|
+
for(const name of names) blocks.push({name,
|
|
18
|
+
html:await fs.readFile(new URL(`../blocks/${name}.html`,import.meta.url),'utf8'),
|
|
19
|
+
css:await fs.readFile(new URL(`../blocks/${name}.css`,import.meta.url),'utf8')});
|
|
20
|
+
await store.publish({format:'domma-block-pack',schema:1,id:'domma-cards',version:DOMMA_CARDS.version,title:'Domma cards',
|
|
21
|
+
description:'Cushion, service, pricing, profile and testimonial designs. Editable parameters with rich content slots on the cushion card.',requires:{slots:1},blocks});
|
|
22
|
+
}
|