domma-cms 1.63.0 → 1.65.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 +16 -0
- package/CLAUDE.md +6 -1
- package/admin/css/admin.css +1 -1
- package/admin/js/lib/background-builder.js +24 -0
- package/admin/js/lib/card-builder.js +2 -2
- package/admin/js/lib/code-format.js +1 -1
- package/admin/js/lib/page-editor-reference.js +23 -3
- package/admin/js/lib/shortcode-form.js +3 -3
- package/admin/js/lib/shortcode-registry.js +10 -8
- package/admin/js/lib/shortcode-tags.js +1 -1
- package/admin/js/lib/theme-settings-arrange.js +1 -1
- package/admin/js/templates/docs/usage-shortcodes.html +5 -1
- package/admin/js/templates/theme.html +7 -0
- package/admin/js/views/theme.js +4 -4
- package/docs/markdown-shortcodes.md +55 -3
- package/docs/screenshots/background-designer.png +0 -0
- package/docs/screenshots/background-nested-layout-desktop.png +0 -0
- package/docs/screenshots/background-nested-layout-mobile.png +0 -0
- package/docs/screenshots/vertical-alignment-builder.png +0 -0
- package/docs/screenshots/vertical-alignment-cards.png +0 -0
- package/docs/theming.md +17 -0
- package/package.json +1 -1
- package/public/css/site.css +1 -1
- package/public/js/background-style.mjs +1 -0
- package/server/services/block-slots.js +1 -1
- package/server/services/content.js +5 -5
- package/server/services/markdown.js +86 -76
- package/server/services/renderer.js +5 -3
- package/server/services/themeSettings.js +4 -0
- package/server/templates/page.html +1 -1
|
@@ -13,7 +13,7 @@ export function pairedRanges(text, names) {
|
|
|
13
13
|
const stack = [], pairs = [];
|
|
14
14
|
const re = /\[(\/)?([a-z][\w-]*)(?=[\s/\]])((?:"[^"]*"|'[^']*'|[^\]"'])*?)\]/gi;
|
|
15
15
|
for (const m of text.matchAll(re)) {
|
|
16
|
-
const name = m[2];
|
|
16
|
+
const name = m[2].toLowerCase();
|
|
17
17
|
if (!names.has(name) || /\/\s*$/.test(m[3])) continue;
|
|
18
18
|
if (!m[1]) { stack.push({name, start:m.index, bodyStart:m.index + m[0].length, attrs:m[3]}); continue; }
|
|
19
19
|
const at = stack.findLastIndex(open => open.name === name);
|
|
@@ -120,7 +120,7 @@ async function readPageSummary(filePath) {
|
|
|
120
120
|
* for a few hundred. A caller that reads only the front matter (title, status,
|
|
121
121
|
* layout, tags, seo, ...) or the Markdown source (`content`) asks for
|
|
122
122
|
* `{render: false}` and gets exactly those plus `urlPath` and
|
|
123
|
-
* `resolvedProject`: no `html`, `usedComponents`, `cacheTags`, `perViewer` or
|
|
123
|
+
* `resolvedProject`: no `html`, `background`, `usedComponents`, `cacheTags`, `perViewer` or
|
|
124
124
|
* `hasExpiry`. Lists, badges, search and the sitemap all do.
|
|
125
125
|
*
|
|
126
126
|
* The rendered rows come through the parsed-page memo while the response
|
|
@@ -224,9 +224,9 @@ export async function getPage(urlPath, opts = {}) {
|
|
|
224
224
|
*/
|
|
225
225
|
export async function buildPreviewPage(urlPath, frontmatter, body, opts = {}) {
|
|
226
226
|
const raw = serialiseMarkdown({...(frontmatter || {})}, body || '');
|
|
227
|
-
const {data, content, html, usedComponents, tags, perViewer, hasExpiry} =
|
|
227
|
+
const {data, content, html, background, usedComponents, tags, perViewer, hasExpiry} =
|
|
228
228
|
await parseMarkdown(raw, {user: opts.user || null, urlPath, expiry:{preview:true}});
|
|
229
|
-
return {...data, urlPath, content, html, usedComponents, cacheTags: tags, perViewer, hasExpiry};
|
|
229
|
+
return {...data, urlPath, content, html, background, usedComponents, cacheTags: tags, perViewer, hasExpiry};
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
/**
|
|
@@ -625,7 +625,7 @@ async function readPageFile(filePath, opts = {}) {
|
|
|
625
625
|
const urlPath = filePathToUrlPath(filePath);
|
|
626
626
|
// urlPath is passed through so `[menu location="…"]` in the body resolves
|
|
627
627
|
// against menus bound to this page or its project, exactly as the navbar does.
|
|
628
|
-
const { data, content, html, usedComponents, tags, perViewer, hasExpiry } =
|
|
628
|
+
const { data, content, html, background, usedComponents, tags, perViewer, hasExpiry } =
|
|
629
629
|
await parseMarkdown(raw, {user: opts.user || null, urlPath, expiry:opts.expiry || (opts.user ? {preview:true} : {})});
|
|
630
630
|
// parseMarkdown's `tags` are CACHE tags (`block:x`, `collection:y`), not
|
|
631
631
|
// the page's editorial tags. Spreading them last used to shadow the
|
|
@@ -634,7 +634,7 @@ async function readPageFile(filePath, opts = {}) {
|
|
|
634
634
|
// cache internals in its Tags column. Keep them apart.
|
|
635
635
|
// perViewer: a row-scoped [view] renders per user - the public route keeps
|
|
636
636
|
// such a page out of the role-keyed response cache for signed-in viewers.
|
|
637
|
-
return { ...data, urlPath, content, html, usedComponents, cacheTags: tags, perViewer, hasExpiry };
|
|
637
|
+
return { ...data, urlPath, content, html, background, usedComponents, cacheTags: tags, perViewer, hasExpiry };
|
|
638
638
|
}
|
|
639
639
|
|
|
640
640
|
/**
|
|
@@ -3,6 +3,7 @@ import {decodeMessageAttribute} from '../../public/js/celebrations/message-attrs
|
|
|
3
3
|
* Markdown Service
|
|
4
4
|
* Parses frontmatter with gray-matter and renders Markdown to HTML with marked.
|
|
5
5
|
*/
|
|
6
|
+
import {normaliseBackground, backgroundStyle} from '../../public/js/background-style.mjs';
|
|
6
7
|
import {cssClasses} from '../../public/js/css-classes.mjs';
|
|
7
8
|
import matter from 'gray-matter';
|
|
8
9
|
import {marked} from 'marked';
|
|
@@ -41,7 +42,7 @@ export const BUILTIN_SHORTCODES = new Set([
|
|
|
41
42
|
'accordion', 'item', 'carousel', 'slide', 'countdown', 'timeline',
|
|
42
43
|
'event', 'listgroup', 'spacer', 'center', 'icon', 'demo', 'embed', 'map', 'image', 'form', 'hero', 'table', 'badge',
|
|
43
44
|
'text', 'button', 'link', 'cta', 'grid', 'row', 'col', 'card', 'box',
|
|
44
|
-
'banner', 'slideover', 'menu',
|
|
45
|
+
'banner', 'slideover', 'menu', 'background',
|
|
45
46
|
// effects
|
|
46
47
|
'counter', 'celebrate', 'firework', 'fireworks', 'scribe',
|
|
47
48
|
'reveal', 'breathe', 'pulse', 'shake', 'scramble', 'ripple', 'twinkle',
|
|
@@ -1993,7 +1994,7 @@ let scrubCallId = 0;
|
|
|
1993
1994
|
* (a nested list, code) keeps the difference. The indent is only ever for the reader.
|
|
1994
1995
|
*/
|
|
1995
1996
|
export const SHORT_TAG_CONTAINERS = Object.freeze([
|
|
1996
|
-
'grid', 'row', 'col', 'card', 'box', 'header', 'footer', 'tabs', 'tab', 'accordion', 'item', 'carousel', 'slide',
|
|
1997
|
+
'background', 'grid', 'row', 'col', 'card', 'box', 'header', 'footer', 'tabs', 'tab', 'accordion', 'item', 'carousel', 'slide',
|
|
1997
1998
|
'timeline', 'event', 'hero', 'banner', 'slideover', 'center', 'listgroup', 'table', 'dconfig', 'reveal', 'animate',
|
|
1998
1999
|
'pulse', 'shake', 'scramble', 'ripple', 'breathe', 'ambient', 'twinkle', 'fireworks', 'scribe', 'wait', 'render', 'redraw'
|
|
1999
2000
|
]);
|
|
@@ -2454,81 +2455,89 @@ function responsiveGridCols(cols) {
|
|
|
2454
2455
|
return map[String(cols)] ?? [`grid-cols-${classToken(cols)}`];
|
|
2455
2456
|
}
|
|
2456
2457
|
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
(_, attrStr, body) => {
|
|
2464
|
-
const attrs = parseShortcodeAttrs(attrStr);
|
|
2465
|
-
const COL_INJECTABLE = ['reveal', 'breathe', 'animate', 'ripple'];
|
|
2466
|
-
const injected = extractInjectedEffects(attrs, COL_INJECTABLE);
|
|
2467
|
-
const baseCls = attrs.span ? `col-span-${classToken(attrs.span)}` : 'col';
|
|
2468
|
-
// Explicit alignment takes precedence over the shorthand flags.
|
|
2469
|
-
const alignment = typeof attrs.align === 'string'
|
|
2470
|
-
? attrs.align.trim().toLowerCase()
|
|
2471
|
-
: ['center', 'centre', 'left', 'right'].find(value => attrs[value] === true);
|
|
2472
|
-
const align = alignment === 'centre' ? 'center' : alignment;
|
|
2473
|
-
const alignClasses = ['left', 'center', 'right'].includes(align) ? [`text-${align}`] : [];
|
|
2474
|
-
const allClasses = [baseCls, ...alignClasses, ...injected.effectClasses].join(' ');
|
|
2475
|
-
const cls = ` class="${allClasses}"`;
|
|
2476
|
-
const id = attrs.id ? ` id="${escapeAttr(attrs.id)}"` : '';
|
|
2477
|
-
// Restore the col body before passing it downstream - otherwise the
|
|
2478
|
-
// scrub placeholders from this processor's store get carried into
|
|
2479
|
-
// processCardBlocks, which creates its own empty store and fails to
|
|
2480
|
-
// decode them, producing the literal string "undefined" in place of
|
|
2481
|
-
// whatever was in <pre>, ``` fences, or `inline code`.
|
|
2482
|
-
return `<div${cls}${id}${injected.effectDataAttrs}>${markedBody(processCardBlocks(processInlineShortcodes(restore(body.trim()))))}</div>`;
|
|
2483
|
-
}
|
|
2484
|
-
);
|
|
2485
|
-
|
|
2486
|
-
// Pass 2: [row gap="N" class="extra" reveal reveal-mode="stagger"]...[/row]
|
|
2487
|
-
result = result.replace(
|
|
2488
|
-
/\[row([^\]]*)\]([\s\S]*?)\[\/row\]/gi,
|
|
2489
|
-
(_, attrStr, inner) => {
|
|
2490
|
-
const attrs = parseShortcodeAttrs(attrStr);
|
|
2491
|
-
const classes = ['row'];
|
|
2492
|
-
if (attrs.gap) classes.push(`gap-${classToken(attrs.gap)}`);
|
|
2493
|
-
if (attrs.class) classes.push(escapeAttr(attrs.class));
|
|
2494
|
-
const id = attrs.id ? ` id="${escapeAttr(attrs.id)}"` : '';
|
|
2495
|
-
const reveal = attrs.reveal !== undefined ? ' data-reveal="true"' : '';
|
|
2496
|
-
const revealMode = attrs['reveal-mode'] ? ` data-reveal-mode="${escapeAttr(attrs['reveal-mode'])}"` : '';
|
|
2497
|
-
const revealAnimation = attrs['reveal-animation'] ? ` data-reveal-animation="${escapeAttr(attrs['reveal-animation'])}"` : '';
|
|
2498
|
-
const revealDuration = attrs['reveal-duration'] ? ` data-reveal-duration="${escapeAttr(attrs['reveal-duration'])}"` : '';
|
|
2499
|
-
const revealStagger = attrs['reveal-stagger'] ? ` data-reveal-stagger="${escapeAttr(attrs['reveal-stagger'])}"` : '';
|
|
2500
|
-
const revealDelay = attrs['reveal-delay'] ? ` data-reveal-delay="${escapeAttr(attrs['reveal-delay'])}"` : '';
|
|
2501
|
-
const revealDirection = attrs['reveal-direction'] ? ` data-reveal-direction="${escapeAttr(attrs['reveal-direction'])}"` : '';
|
|
2502
|
-
// Swoosh in again each time the row comes back up into view; cards that lean toward the pointer.
|
|
2503
|
-
const revealReplay = isTruthyAttr(attrs['reveal-replay']) ? ' data-reveal-replay="true"' : '';
|
|
2504
|
-
const tilt = isTruthyAttr(attrs.tilt) ? ' data-tilt="true"' : '';
|
|
2505
|
-
return `<div class="${classes.join(' ')}"${id}${reveal}${revealMode}${revealAnimation}${revealDuration}${revealStagger}${revealDelay}${revealDirection}${revealReplay}${tilt}>${inner}</div>\n`;
|
|
2506
|
-
}
|
|
2507
|
-
);
|
|
2458
|
+
/** A shared, allowlisted vertical alignment for layout containers and card bodies. */
|
|
2459
|
+
function verticalAlignClasses(attrs) {
|
|
2460
|
+
const raw = typeof attrs['vertical-align'] === 'string' ? attrs['vertical-align'].trim().toLowerCase() : '';
|
|
2461
|
+
const value = ['center', 'centre'].includes(raw) ? 'middle' : raw;
|
|
2462
|
+
return ['top', 'middle', 'bottom'].includes(value) ? [`cms-valign-${value}`] : [];
|
|
2463
|
+
}
|
|
2508
2464
|
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2465
|
+
// Parse balanced containers from the outside, restoring code before entering each child store.
|
|
2466
|
+
function processGridBlocks(markdown, depth = 0) {
|
|
2467
|
+
if (depth >= 64) return markdown;
|
|
2468
|
+
const {scrubbed, restore} = scrubCodeRegions(markdown);
|
|
2469
|
+
const renderers = {
|
|
2470
|
+
background: (attrStr, inner) => {
|
|
2471
|
+
const css = backgroundStyle(parseShortcodeAttrs(attrStr));
|
|
2472
|
+
const body = markedBody(processCardBlocks(processInlineShortcodes(inner.trim())));
|
|
2473
|
+
return `<section class="cms-background"${css ? ` style="${escapeAttr(css)}"` : ''}>${body}</section>\n`;
|
|
2474
|
+
},
|
|
2475
|
+
col: (attrStr, body) => {
|
|
2476
|
+
const attrs = parseShortcodeAttrs(attrStr);
|
|
2477
|
+
const injected = extractInjectedEffects(attrs, ['reveal', 'breathe', 'animate', 'ripple']);
|
|
2478
|
+
const baseCls = attrs.span ? `col-span-${classToken(attrs.span)}` : 'col';
|
|
2479
|
+
// Explicit alignment takes precedence over the shorthand flags.
|
|
2480
|
+
const alignment = typeof attrs.align === 'string'
|
|
2481
|
+
? attrs.align.trim().toLowerCase()
|
|
2482
|
+
: ['center', 'centre', 'left', 'right'].find(value => attrs[value] === true);
|
|
2483
|
+
const align = alignment === 'centre' ? 'center' : alignment;
|
|
2484
|
+
const alignClasses = ['left', 'center', 'right'].includes(align) ? [`text-${align}`] : [];
|
|
2485
|
+
const classes = [baseCls, ...alignClasses, ...verticalAlignClasses(attrs), ...injected.effectClasses];
|
|
2486
|
+
const id = attrs.id ? ` id="${escapeAttr(attrs.id)}"` : '';
|
|
2487
|
+
return `<div class="${classes.join(' ')}"${id}${injected.effectDataAttrs}>${markedBody(processCardBlocks(processInlineShortcodes(body.trim())))}</div>`;
|
|
2488
|
+
},
|
|
2489
|
+
row: (attrStr, inner) => {
|
|
2490
|
+
const attrs = parseShortcodeAttrs(attrStr);
|
|
2491
|
+
const classes = ['row', ...verticalAlignClasses(attrs)];
|
|
2492
|
+
if (attrs.gap) classes.push(`gap-${classToken(attrs.gap)}`);
|
|
2493
|
+
if (attrs.class) classes.push(escapeAttr(attrs.class));
|
|
2494
|
+
const id = attrs.id ? ` id="${escapeAttr(attrs.id)}"` : '';
|
|
2495
|
+
const reveal = attrs.reveal !== undefined ? ' data-reveal="true"' : '';
|
|
2496
|
+
const revealMode = attrs['reveal-mode'] ? ` data-reveal-mode="${escapeAttr(attrs['reveal-mode'])}"` : '';
|
|
2497
|
+
const revealAnimation = attrs['reveal-animation'] ? ` data-reveal-animation="${escapeAttr(attrs['reveal-animation'])}"` : '';
|
|
2498
|
+
const revealDuration = attrs['reveal-duration'] ? ` data-reveal-duration="${escapeAttr(attrs['reveal-duration'])}"` : '';
|
|
2499
|
+
const revealStagger = attrs['reveal-stagger'] ? ` data-reveal-stagger="${escapeAttr(attrs['reveal-stagger'])}"` : '';
|
|
2500
|
+
const revealDelay = attrs['reveal-delay'] ? ` data-reveal-delay="${escapeAttr(attrs['reveal-delay'])}"` : '';
|
|
2501
|
+
const revealDirection = attrs['reveal-direction'] ? ` data-reveal-direction="${escapeAttr(attrs['reveal-direction'])}"` : '';
|
|
2502
|
+
const revealReplay = isTruthyAttr(attrs['reveal-replay']) ? ' data-reveal-replay="true"' : '';
|
|
2503
|
+
const tilt = isTruthyAttr(attrs.tilt) ? ' data-tilt="true"' : '';
|
|
2504
|
+
return `<div class="${classes.join(' ')}"${id}${reveal}${revealMode}${revealAnimation}${revealDuration}${revealStagger}${revealDelay}${revealDirection}${revealReplay}${tilt}>${markedBody(processCardBlocks(processInlineShortcodes(inner.trim())))}</div>\n`;
|
|
2505
|
+
},
|
|
2506
|
+
grid: (attrStr, inner) => {
|
|
2507
|
+
const attrs = parseShortcodeAttrs(attrStr);
|
|
2508
|
+
const classes = ['grid', ...verticalAlignClasses(attrs)];
|
|
2509
|
+
if (attrs.cols) {
|
|
2510
|
+
classes.push(...(attrs.responsive === 'false'
|
|
2511
|
+
? [`grid-cols-${classToken(attrs.cols)}`]
|
|
2512
|
+
: responsiveGridCols(attrs.cols)));
|
|
2521
2513
|
}
|
|
2514
|
+
if (attrs.gap) classes.push(`gap-${classToken(attrs.gap)}`);
|
|
2515
|
+
if (attrs.class) classes.push(escapeAttr(attrs.class));
|
|
2516
|
+
if (attrs.fullwidth === 'true') classes.push('grid-breakout');
|
|
2517
|
+
const id = attrs.id ? ` id="${escapeAttr(attrs.id)}"` : '';
|
|
2518
|
+
return `<div class="${classes.join(' ')}"${id}>${markedBody(processCardBlocks(processInlineShortcodes(inner.trim())))}</div>\n`;
|
|
2522
2519
|
}
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2520
|
+
};
|
|
2521
|
+
let result = scrubbed;
|
|
2522
|
+
for (const range of pairedRanges(scrubbed, new Set(['grid', 'row', 'col', 'background'])).reverse()) {
|
|
2523
|
+
const inner = processGridBlocks(restore(scrubbed.slice(range.bodyStart, range.bodyEnd)), depth + 1);
|
|
2524
|
+
const html = renderers[range.name](range.attrs, inner);
|
|
2525
|
+
result = result.slice(0, range.start) + html + result.slice(range.end);
|
|
2528
2526
|
}
|
|
2529
|
-
|
|
2527
|
+
return restore(result);
|
|
2528
|
+
}
|
|
2530
2529
|
|
|
2531
|
-
|
|
2530
|
+
/** Extract page-level singleton tags before any container can render or escape them. */
|
|
2531
|
+
function extractPageBackground(markdown) {
|
|
2532
|
+
const {scrubbed, restore} = scrubCodeRegions(markdown);
|
|
2533
|
+
const sections = pairedRanges(scrubbed, new Set(['background']));
|
|
2534
|
+
let background = null;
|
|
2535
|
+
const output = scrubbed.replace(/\[background(?=[\s/\]])((?:"[^"]*"|'[^']*'|[^\]"'])*?)\]/gi, (tag, attrs, offset) => {
|
|
2536
|
+
if (sections.some(range => offset >= range.start && offset < range.end)) return tag;
|
|
2537
|
+
background = normaliseBackground(parseShortcodeAttrs(attrs.replace(/\/\s*$/, ''))) || background;
|
|
2538
|
+
return '';
|
|
2539
|
+
});
|
|
2540
|
+
return {output: restore(output), background};
|
|
2532
2541
|
}
|
|
2533
2542
|
|
|
2534
2543
|
/**
|
|
@@ -2679,7 +2688,7 @@ function isHoverOff(value) {
|
|
|
2679
2688
|
function cardVariantClasses(attrs) {
|
|
2680
2689
|
const variant = typeof attrs.variant === 'string' ? attrs.variant.trim() : '';
|
|
2681
2690
|
const gradient = typeof attrs.gradient === 'string' ? attrs.gradient.trim() : 'indigo';
|
|
2682
|
-
const classes = ['card', 'mb-4'];
|
|
2691
|
+
const classes = ['card', 'mb-4', ...verticalAlignClasses(attrs)];
|
|
2683
2692
|
const valid = ['clean', 'gradient', 'glass', 'accent', 'dark', 'glow'];
|
|
2684
2693
|
if (valid.includes(variant)) {
|
|
2685
2694
|
classes.push(`dm-card-${variant}`);
|
|
@@ -5471,7 +5480,7 @@ export async function parseMarkdown(raw, opts = {}) {
|
|
|
5471
5480
|
// → dconfig → effects → plugin shortcodes → tabs → accordion → carousel → countdown → timeline
|
|
5472
5481
|
// → listgroup → spacer → center → icon → demo → embed → image → form → hero → table
|
|
5473
5482
|
// → badge → text → button → link → cta → grid → card (+ box) → banner → slideover
|
|
5474
|
-
// → marked → sanitize → afterParse
|
|
5483
|
+
// → background → marked → sanitize → afterParse
|
|
5475
5484
|
// Comments must be removed before shortcodes are expanded. Protect code
|
|
5476
5485
|
// examples first; four-space-indented lines remain Markdown code too.
|
|
5477
5486
|
const comments = scrubCodeRegions(content, true);
|
|
@@ -5483,7 +5492,8 @@ export async function parseMarkdown(raw, opts = {}) {
|
|
|
5483
5492
|
...(opts.expiry || {}), urlPath: opts.urlPath || '/', parseAttrs: parseShortcodeAttrs
|
|
5484
5493
|
});
|
|
5485
5494
|
const visible = expirySafe.restore(expiry.markdown);
|
|
5486
|
-
const
|
|
5495
|
+
const withBackground = extractPageBackground(visible);
|
|
5496
|
+
const preprocessed = opts[SLOT_FRAGMENT] ? withBackground.output : applyTransforms('markdown:beforeParse', withBackground.output);
|
|
5487
5497
|
const tagSet = new Set();
|
|
5488
5498
|
const flags = {perViewer: false, hasExpiry:expiry.hasExpiry};
|
|
5489
5499
|
const slotComponents = new Set();
|
|
@@ -5538,7 +5548,7 @@ export async function parseMarkdown(raw, opts = {}) {
|
|
|
5538
5548
|
const filteredUsed = [...usedComponents].filter(name => allowed.has(name));
|
|
5539
5549
|
|
|
5540
5550
|
// `content` is the body as written: the editor loads it from here, and the nesting indent is the person's.
|
|
5541
|
-
return {data, content: written, html, usedComponents: filteredUsed, tags: [...tagSet], perViewer: flags.perViewer, hasExpiry:flags.hasExpiry};
|
|
5551
|
+
return {data, content: written, html, background: withBackground.background, usedComponents: filteredUsed, tags: [...tagSet], perViewer: flags.perViewer, hasExpiry:flags.hasExpiry};
|
|
5542
5552
|
}
|
|
5543
5553
|
|
|
5544
5554
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {pageBackgroundStyleTag} from '../../public/js/background-style.mjs';
|
|
1
2
|
/**
|
|
2
3
|
* Renderer Service
|
|
3
4
|
* Assembles the full HTML page shell from the template + page data + site config.
|
|
@@ -672,7 +673,7 @@ export async function renderPage(page, opts = {}) {
|
|
|
672
673
|
// generated, custom.css is hand-written, and the hand-written one stays
|
|
673
674
|
// the last word.
|
|
674
675
|
headInjectLate: [injection.headLate, searchAssets.headTag, motionAssets.headTag, embed ? '' : switcherAssets.headTag,
|
|
675
|
-
launcherAssets.headTag, embed ? EMBED_HEAD_TAG : '', themeView.customThemeStyleTag, themeView.overrideStyleTag, customCssTag, navbarStyleTag]
|
|
676
|
+
launcherAssets.headTag, embed ? EMBED_HEAD_TAG : '', themeView.customThemeStyleTag, themeView.overrideStyleTag, themeView.backgroundStyleTag, customCssTag, navbarStyleTag]
|
|
676
677
|
.filter(Boolean).join('\n'),
|
|
677
678
|
bodyEndInject: [
|
|
678
679
|
// Draft banner - first, so it is the topmost fixed element and a
|
|
@@ -1189,7 +1190,8 @@ async function buildThemeView(page = {}) {
|
|
|
1189
1190
|
fontStyleTag: fontOverride ? `<style>${fontOverride}</style>` : '',
|
|
1190
1191
|
// Only the custom themes this page can show: its own, and day/night's.
|
|
1191
1192
|
customThemeStyleTag: buildCustomThemeStyleTag([activeTheme, autoTheme?.dayTheme, autoTheme?.nightTheme]),
|
|
1192
|
-
overrideStyleTag: buildOverrideStyleTag(cfg)
|
|
1193
|
+
overrideStyleTag: buildOverrideStyleTag(cfg),
|
|
1194
|
+
backgroundStyleTag: pageBackgroundStyleTag(page.background || cfg.background)
|
|
1193
1195
|
};
|
|
1194
1196
|
}
|
|
1195
1197
|
|
|
@@ -1455,7 +1457,7 @@ export async function renderBlogPage(templatePath, data = {}, seoMeta = {}) {
|
|
|
1455
1457
|
// Theme overrides land BEFORE content/custom.css: the overrides are
|
|
1456
1458
|
// generated, custom.css is hand-written, and the hand-written one stays
|
|
1457
1459
|
// the last word.
|
|
1458
|
-
headInjectLate: [bare ? '' : injection.headLate, searchAssets.headTag, motionAssets.headTag, switcherAssets.headTag, launcherAssets.headTag, themeView.customThemeStyleTag, themeView.overrideStyleTag, customCssTag, navbarStyleTag]
|
|
1460
|
+
headInjectLate: [bare ? '' : injection.headLate, searchAssets.headTag, motionAssets.headTag, switcherAssets.headTag, launcherAssets.headTag, themeView.customThemeStyleTag, themeView.overrideStyleTag, themeView.backgroundStyleTag, customCssTag, navbarStyleTag]
|
|
1459
1461
|
.filter(Boolean).join('\n'),
|
|
1460
1462
|
bodyEndInject: [
|
|
1461
1463
|
overlayMenus,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {normaliseBackground} from '../../public/js/background-style.mjs';
|
|
1
2
|
/**
|
|
2
3
|
* Theme settings - config/theme.json.
|
|
3
4
|
*
|
|
@@ -109,6 +110,7 @@ export function defaultThemeConfig() {
|
|
|
109
110
|
lightTheme: 'charcoal-light',
|
|
110
111
|
darkTheme: 'charcoal-dark'
|
|
111
112
|
},
|
|
113
|
+
background: null,
|
|
112
114
|
overrides: []
|
|
113
115
|
};
|
|
114
116
|
}
|
|
@@ -412,6 +414,7 @@ function definedOnly(obj) {
|
|
|
412
414
|
function mergeDefaults(raw) {
|
|
413
415
|
const d = defaultThemeConfig();
|
|
414
416
|
const cfg = {...d, ...definedOnly(raw)};
|
|
417
|
+
cfg.background = normaliseBackground(raw?.background);
|
|
415
418
|
cfg.autoTheme = {...d.autoTheme, ...definedOnly(raw?.autoTheme)};
|
|
416
419
|
cfg.font = {...d.font, ...definedOnly(raw?.font)};
|
|
417
420
|
cfg.switcher = {...d.switcher, ...definedOnly(raw?.switcher)};
|
|
@@ -649,6 +652,7 @@ export function validateThemeConfig(input, {remembered = [], currentSwitcher = {
|
|
|
649
652
|
const errors = [];
|
|
650
653
|
if (!input || typeof input !== 'object') return ['Theme config must be an object'];
|
|
651
654
|
|
|
655
|
+
if (input.background != null && !normaliseBackground(input.background)) errors.push('Choose a valid background type, preset or colour');
|
|
652
656
|
const builtins = listThemeIds();
|
|
653
657
|
// Custom themes (a plugin's) are chosen like any other - except by the
|
|
654
658
|
// public switcher below, which switches through Domma's engine. One the
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
<link rel="stylesheet" href="/dist/domma/themes/domma-themes.css">
|
|
26
26
|
|
|
27
27
|
<!-- Site CSS -->
|
|
28
|
-
<link rel="stylesheet" href="/public/css/site.css?v=
|
|
28
|
+
<link rel="stylesheet" href="/public/css/site.css?v=20261113-vertical-align">
|
|
29
29
|
<link rel="stylesheet" href="/public/css/forms.css?v=20261031-forms-reduce-motion">
|
|
30
30
|
<!-- Menu item hover / current-page effects. Loaded after site.css so a
|
|
31
31
|
menu's own highlight wins over the blanket link styling there. -->
|