@ecomcx/ecomweb-theme-sdk 1.35.0 → 1.37.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.
@@ -37,11 +37,13 @@ export declare function Pagination({ data, prevLabel, nextLabel, pageParam, type
37
37
  midSize?: number;
38
38
  }): Promise<import("react").JSX.Element | null>;
39
39
  /** Ảnh đại diện: responsive, WebP, srcset. */
40
- export declare function FeaturedImage({ media, size, className, link, sizes, priority }: {
40
+ /** `label`: tên của link khi ảnh chưa có alt (thường là tiêu đề bài) — không có thì trình đọc màn hình chỉ đọc "liên kết". */
41
+ export declare function FeaturedImage({ media, size, className, link, label, sizes, priority }: {
41
42
  media?: Media | null;
42
43
  size?: string;
43
44
  className?: string;
44
45
  link?: string;
46
+ label?: string;
45
47
  sizes?: string;
46
48
  priority?: boolean;
47
49
  }): import("react").JSX.Element | null;
@@ -120,11 +120,13 @@ export async function Pagination({ data, prevLabel, nextLabel, pageParam, type =
120
120
  : _jsx(Link, { href: link(p), children: p }, p)), type !== "numbers" && data.page < data.totalPages && _jsx(Link, { className: "next", href: link(data.page + 1), children: nextLabel })] }));
121
121
  }
122
122
  /** Ảnh đại diện: responsive, WebP, srcset. */
123
- export function FeaturedImage({ media, size = "large", className, link, sizes, priority }) {
123
+ /** `label`: tên của link khi ảnh chưa có alt (thường là tiêu đề bài) — không có thì trình đọc màn hình chỉ đọc "liên kết". */
124
+ export function FeaturedImage({ media, size = "large", className, link, label, sizes, priority }) {
124
125
  if (!media)
125
126
  return null;
126
127
  const img = _jsx(Img, { media: media, size: size, sizes: sizes, priority: priority });
127
- return _jsx("figure", { className: cx("featured-image", className), children: link ? _jsx(Link, { href: link, children: img }) : img });
128
+ const name = link && !media.alt?.trim() && label?.trim() ? label : undefined;
129
+ return _jsx("figure", { className: cx("featured-image", className), children: link ? _jsx(Link, { href: link, "aria-label": name, children: img }) : img });
128
130
  }
129
131
  export function PostDate({ post, site }) {
130
132
  return _jsx("time", { dateTime: post.publishedAt ?? post.createdAt, children: formatDate(post.publishedAt ?? post.createdAt, site) });
package/dist/dynamic.js CHANGED
@@ -4,6 +4,7 @@ import { getArchives, getPosts, getTerms } from "./api.js";
4
4
  import { Link, LoginOutLink } from "./client.js";
5
5
  import { Comments, FeaturedImage, LanguageSwitcher, Menu, Pagination, PostDate, SearchForm, TermLinks } from "./components.js";
6
6
  import { getT } from "./i18n.js";
7
+ import { applyFilters } from "./runtime.js";
7
8
  import { localeHref } from "./locale.js";
8
9
  import { renderContent } from "./rich.js";
9
10
  import { cx } from "./utils.js";
@@ -66,7 +67,7 @@ export async function renderDynamic(node, key, ctx, children) {
66
67
  if (!post?.featuredMedia)
67
68
  return null;
68
69
  const ratio = ASPECT[a.aspect];
69
- return _jsx("div", { className: "ecx-featured-image", style: ratio ? { aspectRatio: ratio, overflow: "hidden" } : undefined, children: _jsx(FeaturedImage, { media: post.featuredMedia, size: a.size ?? "large", link: a.link ? post.link : undefined }) }, key);
70
+ return _jsx("div", { className: "ecx-featured-image", style: ratio ? { aspectRatio: ratio, overflow: "hidden" } : undefined, children: _jsx(FeaturedImage, { media: post.featuredMedia, size: a.size ?? "large", link: a.link ? post.link : undefined, label: post.title }) }, key);
70
71
  }
71
72
  case "postDate":
72
73
  return post ? _jsx("p", { className: "ecx-post-date", style: align(a), children: _jsx(PostDate, { post: a.displayType === "modified" ? { ...post, publishedAt: post.updatedAt } : post, site: site }) }, key) : null;
@@ -175,8 +176,9 @@ export async function renderDynamic(node, key, ctx, children) {
175
176
  return null;
176
177
  const base = (site.url ?? "").replace(/\/$/, "");
177
178
  // Schema BreadcrumbList: Google hiện đường dẫn thay cho URL trong kết quả tìm kiếm
178
- const jsonLd = { "@context": "https://schema.org", "@type": "BreadcrumbList", itemListElement: items.map((it, i) => ({ "@type": "ListItem", position: i + 1, name: it.name, ...(it.href ? { item: /^https?:/.test(it.href) ? it.href : base + it.href } : {}) })) };
179
- return (_jsxs("nav", { className: "ecx-breadcrumbs", "aria-label": t("breadcrumbs.label"), children: [_jsx("ol", { children: items.map((it, i) => _jsxs("li", { children: [i > 0 && _jsx("span", { className: "ecx-breadcrumbs-sep", "aria-hidden": "true", children: a.separator ?? "›" }), it.href ? _jsx(Link, { href: it.href, children: it.name }) : _jsx("span", { "aria-current": "page", children: it.name })] }, i)) }), _jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: JSON.stringify(jsonLd).replace(/</g, "\\u003c") } })] }, key));
179
+ // Plugin SEO có schema riêng (BreadcrumbList trong @graph) trả null để trang không có hai BreadcrumbList mâu thuẫn
180
+ const jsonLd = await applyFilters("breadcrumbs.schema", { "@context": "https://schema.org", "@type": "BreadcrumbList", itemListElement: items.map((it, i) => ({ "@type": "ListItem", position: i + 1, name: it.name, ...(it.href ? { item: /^https?:/.test(it.href) ? it.href : base + it.href } : {}) })) }, { site, items }, site);
181
+ return (_jsxs("nav", { className: "ecx-breadcrumbs", "aria-label": t("breadcrumbs.label"), children: [_jsx("ol", { children: items.map((it, i) => _jsxs("li", { children: [i > 0 && _jsx("span", { className: "ecx-breadcrumbs-sep", "aria-hidden": "true", children: a.separator ?? "›" }), it.href ? _jsx(Link, { href: it.href, children: it.name }) : _jsx("span", { "aria-current": "page", children: it.name })] }, i)) }), jsonLd && _jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: JSON.stringify(jsonLd).replace(/</g, "\\u003c") } })] }, key));
180
182
  }
181
183
  case "postNavigation": {
182
184
  const cur = ctx.data?.post;
@@ -222,7 +224,8 @@ export async function renderDynamic(node, key, ctx, children) {
222
224
  if (!posts.length)
223
225
  return null;
224
226
  const grid = a.layout === "grid";
225
- const style = grid ? { display: "grid", gap: "1.5rem", gridTemplateColumns: `repeat(auto-fill, minmax(min(100%, ${Math.floor(60 / (a.columns ?? 3))}rem), 1fr))`, listStyle: "none", padding: 0 } : { listStyle: "none", padding: 0 };
227
+ // Đúng N cột khi đủ chỗ (như canvas), ít cột hơn khi hẹp (mỗi cột tối thiểu 12rem) — trước đây N chỉ là gợi ý nên 3 cột thành 2
228
+ const style = grid ? { display: "grid", gap: "1.5rem", gridTemplateColumns: `repeat(auto-fill, minmax(max(12rem, calc((100% - ${(a.columns ?? 3) - 1} * 1.5rem) / ${a.columns ?? 3})), 1fr))`, listStyle: "none", padding: 0 } : { listStyle: "none", padding: 0 };
226
229
  const items = await Promise.all(posts.map(async (p) => _jsx("li", { className: "ecx-post", children: await children({ ...ctx, post: p }) }, p.id)));
227
230
  return _jsx("ul", { className: cx("ecx-post-template", grid && "is-grid"), style: style, children: items }, key);
228
231
  }
package/dist/metadata.js CHANGED
@@ -1,11 +1,12 @@
1
1
  import { applyFilters } from "./runtime.js";
2
+ import { pageLink } from "./utils.js";
2
3
  /** Metadata mặc định cho trang + cho plugin (vd SEO) sửa qua filter "document.metadata". */
3
4
  export async function buildDocumentMetadata(data, site) {
4
5
  const isHome = data.kind === "home" || data.kind === "front-page";
5
6
  const base = {
6
7
  title: isHome ? `${site.title}${site.tagline ? ` – ${site.tagline}` : ""}` : `${data.title} – ${site.title}`,
7
8
  description: data.post?.excerpt || (data.term?.description || undefined) || site.tagline,
8
- canonical: data.post?.link ? data.post.link + (Number(data.query?.trang) > 1 ? `?trang=${Math.floor(Number(data.query?.trang))}` : "") : (data.basePath || undefined),
9
+ canonical: data.post?.link ? data.post.link + (Number(data.query?.trang) > 1 ? `?trang=${Math.floor(Number(data.query?.trang))}` : "") : (data.basePath ? pageLink(data.basePath, Number(data.page) || 1) : undefined), // trang phân trang tự canonical về chính nó (không dồn về trang 1: nội dung mỗi trang khác nhau)
9
10
  alternates: Object.fromEntries((data.alternates ?? []).map((a) => [a.locale, a.link])),
10
11
  openGraph: {
11
12
  title: data.post?.title ?? data.title,
package/dist/rich.js CHANGED
@@ -1,7 +1,7 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Fragment, cloneElement, isValidElement } from "react";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Fragment, cloneElement, createElement, isValidElement } from "react";
3
3
  import { ICON_PATHS } from "./icons.js";
4
- import { DYNAMIC_NODES, colorCss, embedInfo, motionClasses, normalizeContent, safeUrl, spacingValue, styleClass, styleCss } from "@ecomcx/ecomweb-content";
4
+ import { DYNAMIC_NODES, blockCitation, blockShell, buttonWrapShell, coverParts, linkRel, embedInfo, motionClasses, normalizeContent, safeUrl, styleClass, styleCss } from "@ecomcx/ecomweb-content";
5
5
  import { cx } from "./utils.js";
6
6
  import { SOCIAL_ICONS } from "./social-icons.js";
7
7
  import { CountdownClient, LightboxClient, TabsClient } from "./client.js";
@@ -63,6 +63,11 @@ const TONES = { info: "#2563eb", success: "#16a34a", warning: "#d97706", danger:
63
63
  function alignStyle(attrs) {
64
64
  return attrs?.textAlign && attrs.textAlign !== "left" ? { textAlign: attrs.textAlign } : undefined;
65
65
  }
66
+ /** Vẽ khối theo vỏ markup dùng chung với trình soạn (@ecomcx/ecomweb-content › blockShell): thẻ / class / style cùng một nguồn. */
67
+ function shelled(type, a, key, children, extra, parent) {
68
+ const sh = blockShell(type, a, parent);
69
+ return createElement(sh.tag, { key, className: sh.className, ...extra, style: sh.style, ...sh.attrs }, children);
70
+ }
66
71
  function renderMarks(text, marks, key, ctx) {
67
72
  let out = text;
68
73
  for (const [i, m] of (marks ?? []).entries()) {
@@ -107,13 +112,7 @@ function renderMarks(text, marks, key, ctx) {
107
112
  break;
108
113
  case "link": {
109
114
  const target = m.attrs?.target;
110
- // rel do người viết/plugin đặt (nofollow, sponsored, ugc…) + luôn noopener khi mở tab mới
111
- const rel = new Set(String(m.attrs?.rel ?? "").toLowerCase().split(/\s+/).filter((x) => /^[a-z-]+$/.test(x)));
112
- if (target === "_blank") {
113
- rel.add("noopener");
114
- rel.add("noreferrer");
115
- }
116
- out = _jsx("a", { href: safeUrl(m.attrs?.href), target: target ?? undefined, rel: rel.size ? [...rel].join(" ") : undefined, children: out }, k);
115
+ out = _jsx("a", { href: safeUrl(m.attrs?.href), target: target ?? undefined, rel: linkRel(m.attrs?.rel, target), children: out }, k);
117
116
  break;
118
117
  }
119
118
  }
@@ -255,20 +254,17 @@ async function renderNodeInner(node, key, ctx) {
255
254
  console.warn(`[cms] Shortcode [${sc[1]}] không có plugin nào xử lý — đã ẩn khỏi trang`);
256
255
  return null;
257
256
  }
258
- return _jsx("p", { style: alignStyle(a), children: await children() }, key);
257
+ return shelled("paragraph", a, key, await children());
259
258
  }
260
259
  case "heading": {
261
- const level = Math.min(6, Math.max(1, Number(a.level) || 2));
262
- const Tag = `h${level}`;
263
- const id = headingId(node);
264
- return _jsx(Tag, { id: id || undefined, style: alignStyle(a), children: await children() }, key);
260
+ return shelled("heading", a, key, await children(), { id: headingId(node) || undefined });
265
261
  }
266
262
  case "bulletList": return _jsx("ul", { children: await children() }, key);
267
263
  case "orderedList": return _jsx("ol", { start: a.start && a.start !== 1 ? a.start : undefined, reversed: a.reversed === true || undefined, children: await children() }, key);
268
264
  case "listItem": return _jsx("li", { children: await children() }, key);
269
265
  case "taskList": return _jsx("ul", { className: "ecx-task-list task-list", children: await children() }, key);
270
266
  case "taskItem": return _jsxs("li", { className: "ecx-task-item task-item", children: [_jsx("input", { type: "checkbox", checked: !!a.checked, readOnly: true }), " ", await children()] }, key);
271
- case "blockquote": return _jsxs("blockquote", { children: [await children(), a.citation && _jsx("cite", { children: a.citation })] }, key);
267
+ case "blockquote": return shelled("blockquote", a, key, _jsxs(_Fragment, { children: [await children(), blockCitation(a) && _jsx("cite", { children: blockCitation(a) })] }));
272
268
  case "codeBlock": return _jsx("pre", { children: _jsx("code", { className: a.language ? `language-${a.language}` : undefined, children: plainText(node) }) }, key);
273
269
  case "hardBreak": return _jsx("br", {}, key);
274
270
  case "pageBreak": return null;
@@ -290,18 +286,21 @@ async function renderNodeInner(node, key, ctx) {
290
286
  // Ảnh chèn từ thư viện mang sẵn srcset (JPEG + WebP) và kích thước → responsive, không nhảy layout
291
287
  // Bề rộng hiển thị = cỡ người viết kéo trong trình soạn → trình duyệt chọn file vừa đúng
292
288
  const sizes = a.width ? `(max-width: ${a.width}px) 100vw, ${a.width}px` : (a.sizes || "(max-width: 1024px) 100vw, 1024px");
293
- const img = _jsx("img", { src: safeUrl(a.src, ""), srcSet: a.srcset || undefined, sizes: a.srcset ? sizes : undefined, alt: a.alt ?? "", title: a.title ?? undefined, width: a.width ?? undefined, height: a.height ?? undefined, loading: "lazy", decoding: "async" });
289
+ const imgSrc = safeUrl(a.src, "");
290
+ if (!imgSrc)
291
+ return null; // chưa chọn ảnh: không in <img> không có địa chỉ (hiện icon ảnh hỏng)
292
+ const img = _jsx("img", { src: imgSrc, srcSet: a.srcset || undefined, sizes: a.srcset ? sizes : undefined, alt: a.alt ?? "", title: a.title ?? undefined, width: a.width ?? undefined, height: a.height ?? undefined, loading: "lazy", decoding: "async" });
294
293
  const bare = a.webpSrcset ? _jsxs("picture", { children: [_jsx("source", { type: "image/webp", srcSet: a.webpSrcset, sizes: sizes }), img] }) : img;
295
294
  // next: ảnh có liên kết (href qua safeUrl; mở tab mới thì noopener)
296
295
  const pic = a.lightbox === true && !a.href ? _jsx(LightboxClient, { src: safeUrl(a.src, ""), alt: a.alt ?? "", children: bare }) : a.href ? _jsx("a", { href: safeUrl(a.href), target: a.linkTarget === "_blank" ? "_blank" : undefined, rel: a.linkTarget === "_blank" ? "noopener noreferrer" : undefined, children: bare }) : bare;
297
- const cls = cx("ecx-image cms-image", a.align && `ecx-align-${a.align} align${a.align}`, a.mediaId && `ecx-image-${a.mediaId} cms-image-${a.mediaId}`);
296
+ const cls = blockShell("image", a).className;
298
297
  return a.caption || a.align ? _jsxs("figure", { className: cls, children: [pic, a.caption && _jsx("figcaption", { children: a.caption })] }, key) : _jsx(Fragment, { children: pic }, key);
299
298
  }
300
299
  case "gallery": {
301
300
  const items = (a.images ?? []);
302
301
  const cols = Math.min(6, Math.max(1, Number(a.columns) || 3));
303
302
  const crop = a.imageCrop !== false; // next: imageCrop=false giữ nguyên tỉ lệ ảnh
304
- return (_jsxs("figure", { className: cx("ecx-gallery cms-gallery", `ecx-gallery-columns-${cols} columns-${cols}`), style: { display: "grid", gap: 8, gridTemplateColumns: `repeat(${cols}, minmax(0, 1fr))` }, children: [items.map((im, i) => {
303
+ return (_jsxs("figure", { className: blockShell("gallery", a).className, style: blockShell("gallery", a).style, children: [items.map((im, i) => {
305
304
  const el = _jsx("img", { src: safeUrl(im.src, ""), srcSet: im.srcset || undefined, sizes: `(max-width: 768px) 50vw, ${Math.round(100 / cols)}vw`, alt: im.alt ?? "", width: im.width, height: im.height, loading: "lazy", decoding: "async", style: crop ? { width: "100%", height: "100%", objectFit: "cover", aspectRatio: "1" } : { width: "100%", height: "auto" } });
306
305
  const pic = im.webpSrcset ? _jsxs("picture", { children: [_jsx("source", { type: "image/webp", srcSet: im.webpSrcset, sizes: `(max-width: 768px) 50vw, ${Math.round(100 / cols)}vw` }), el] }) : el;
307
306
  return _jsxs("figure", { className: "ecx-gallery-item cms-gallery-item", style: { margin: 0 }, children: [a.lightbox === true ? _jsx(LightboxClient, { src: safeUrl(im.full || im.src, ""), alt: im.alt ?? "", children: pic }) : im.full && a.linkTo !== "none" ? _jsx("a", { href: safeUrl(im.full), children: pic }) : pic, im.caption && _jsx("figcaption", { children: im.caption })] }, i);
@@ -334,64 +333,39 @@ async function renderNodeInner(node, key, ctx) {
334
333
  }
335
334
  // Bố cục (@ecomcx/ecomweb-content 1.2). Cấu trúc dùng style trực tiếp → mọi theme hiển thị đúng; class `ecx-*` để theme tạo kiểu thêm (`cms-*` giữ tới 2.0).
336
335
  case "columns": {
337
- // Cột co giãn theo tỉ lệ độ rộng; màn hẹp (mỗi cột < 14rem) tự xuống dòng thành một cột — không cần CSS của theme
338
- const stack = a.stack !== false;
339
- const align = a.verticalAlign === "center" ? "center" : a.verticalAlign === "bottom" ? "flex-end" : "flex-start";
340
336
  const cols = await Promise.all((node.content ?? []).map(async (c, i) => {
341
- const w = Number(c.attrs?.width) > 0 ? Number(c.attrs?.width) : 1;
342
337
  const inner = await Promise.all((c.content ?? []).map((cc, j) => renderNode(cc, `${key}-${i}-${j}`, ctx)));
343
- return _jsx("div", { className: "ecx-column cms-column", style: { flex: `${w} 1 0`, minWidth: stack ? "min(100%, 14rem)" : 0 }, children: inner }, `${key}-${i}`);
338
+ return shelled("column", c.attrs ?? {}, `${key}-${i}`, inner, undefined, { type: "columns", attrs: a });
344
339
  }));
345
- return _jsx("div", { className: cx("ecx-columns cms-columns", a.verticalAlign && `ecx-columns-${a.verticalAlign} cms-columns-${a.verticalAlign}`), style: { display: "flex", flexWrap: stack ? "wrap" : "nowrap", gap: "1.5rem", alignItems: align }, children: cols }, key);
346
- }
347
- case "column": return _jsx("div", { className: "ecx-column cms-column", children: await children() }, key);
348
- case "group": {
349
- const bg = safeColor(a.background), fg = safeColor(a.textColor);
350
- const pad = PADDING[a.padding] ?? (bg ? PADDING.medium : undefined);
351
- return _jsx("div", { className: cx("ecx-group cms-group", a.padding && `ecx-group-${a.padding} cms-group-${a.padding}`), style: { background: bg, color: fg, padding: pad, borderRadius: bg ? 12 : undefined }, children: await children() }, key);
352
- }
353
- case "callout": {
354
- const tone = TONES[a.tone] ? a.tone : "info";
355
- return (_jsxs("div", { role: "note", className: cx("ecx-callout cms-callout", `ecx-callout-${tone} cms-callout-${tone}`), style: { borderLeft: `4px solid ${TONES[tone]}`, background: `color-mix(in srgb, ${TONES[tone]} 8%, transparent)`, padding: "0.75rem 1rem", borderRadius: 8 }, children: [a.title && _jsx("p", { className: "ecx-callout-title cms-callout-title", style: { margin: 0, fontWeight: 600 }, children: a.title }), await children()] }, key));
340
+ return shelled("columns", a, key, cols);
356
341
  }
342
+ case "column": return shelled("column", a, key, await children());
343
+ case "group": return shelled("group", a, key, await children());
344
+ case "callout": return shelled("callout", a, key, _jsxs(_Fragment, { children: [a.title && _jsx("p", { className: "ecx-callout-title cms-callout-title", style: { margin: 0, fontWeight: 600 }, children: a.title }), await children()] }));
357
345
  case "button": {
358
346
  if (!a.text)
359
347
  return null;
360
- const variant = a.variant === "secondary" || a.variant === "outline" ? a.variant : "primary";
361
348
  const target = a.target === "_blank" ? "_blank" : undefined;
362
- const rel = new Set(String(a.rel ?? "").toLowerCase().split(/\s+/).filter((x) => /^[a-z-]+$/.test(x)));
363
- if (target) {
364
- rel.add("noopener");
365
- rel.add("noreferrer");
366
- }
367
- const look = variant === "outline"
368
- ? { border: "1px solid var(--ecx-button-bg, var(--cms-button-bg, var(--primary, currentColor)))", color: "var(--ecx-button-bg, var(--cms-button-bg, var(--primary, inherit)))" }
369
- : variant === "secondary"
370
- ? { background: "var(--ecx-button-secondary-bg, var(--cms-button-secondary-bg, rgba(127,127,127,.15)))", color: "inherit" }
371
- : { background: "var(--ecx-button-bg, var(--cms-button-bg, var(--primary, #18181b)))", color: "var(--ecx-button-fg, var(--cms-button-fg, #fff))" };
372
- const link = (_jsx("a", { className: cx("ecx-button cms-button", `ecx-button-${variant} cms-button-${variant}`), href: safeUrl(a.href), target: target, rel: rel.size ? [...rel].join(" ") : undefined, style: { display: "inline-block", padding: "0.6em 1.2em", borderRadius: 8, textDecoration: "none", fontWeight: 600, lineHeight: 1.2, ...look }, children: a.text }, ctx.inButtons ? key : undefined));
349
+ const link = shelled("button", a, ctx.inButtons ? key : "", a.text, { href: safeUrl(a.href), target, rel: linkRel(a.rel, target) });
373
350
  if (ctx.inButtons)
374
351
  return link;
375
- return (_jsx("p", { className: cx("ecx-buttons cms-buttons", a.align && `ecx-buttons-${a.align} cms-buttons-${a.align}`), style: a.align ? { textAlign: a.align } : undefined, children: link }, key));
352
+ return createElement(buttonWrapShell(a).tag, { key, className: buttonWrapShell(a).className, style: buttonWrapShell(a).style }, link);
376
353
  }
377
354
  // Bộ khối cơ bản (@ecomcx/ecomweb-content 1.9)
378
355
  case "spacer":
379
- return _jsx("div", { className: "ecx-spacer", style: { height: spacingValue(a.height ?? "lg") ?? "1.5rem" }, "aria-hidden": "true" }, key);
356
+ return shelled("spacer", a, key, null);
380
357
  case "buttons": {
381
358
  const items = await Promise.all((node.content ?? []).map((c, i) => renderNode(c, `${key}-${i}`, { ...ctx, inButtons: true })));
382
- return _jsx("div", { className: cx("ecx-buttons-group", a.align && `is-${a.align}`), children: items }, key);
359
+ return shelled("buttons", a, key, items);
383
360
  }
384
361
  case "cover": {
385
- const src = a.src ? safeUrl(a.src, "") : "";
386
- const overlay = colorCss(a.overlay) ?? (src ? "#000" : undefined);
387
- return (_jsxs("div", { className: cx("ecx-cover", a.contentAlign && a.contentAlign !== "center" && `is-${a.contentAlign}`, a.fixed && src && "is-fixed"), style: { minHeight: spacingValue(a.minHeight ?? "400px"), backgroundImage: a.fixed && src ? `url("${src.replace(/["\\()]/g, encodeURIComponent)}")` : undefined }, children: [src && !a.fixed && _jsx("img", { className: "ecx-cover-img", src: src, alt: a.alt ?? "", loading: "lazy", decoding: "async" }), overlay && _jsx("span", { className: "ecx-cover-overlay", "aria-hidden": "true", style: { background: overlay, opacity: Math.min(100, Math.max(0, Number(a.opacity ?? 50))) / 100 } }), _jsx("div", { className: "ecx-cover-inner", children: await children() })] }, key));
388
- }
389
- case "mediaText": {
390
- const width = Math.min(80, Math.max(20, Number(a.width) || 50));
391
- return (_jsxs("div", { className: cx("ecx-media-text", a.position === "right" && "is-right", a.verticalAlign && a.verticalAlign !== "center" && `is-${a.verticalAlign}`, a.stack !== false && "is-stack"), style: { ["--ecx-media-width"]: `${width}%` }, children: [_jsx("figure", { className: "ecx-media-text-media", style: { margin: 0 }, children: a.src && _jsx("img", { src: safeUrl(a.src, ""), alt: a.alt ?? "", loading: "lazy", decoding: "async" }) }), _jsx("div", { className: "ecx-media-text-content", children: await children() })] }, key));
362
+ const { src, fixed, overlay, opacity } = coverParts(a);
363
+ const url = src ? safeUrl(src, "") : "";
364
+ return shelled("cover", a, key, _jsxs(_Fragment, { children: [url && !fixed && _jsx("img", { className: "ecx-cover-img", src: url, alt: a.alt ?? "", loading: "lazy", decoding: "async" }), overlay && _jsx("span", { className: "ecx-cover-overlay", "aria-hidden": "true", style: { background: overlay, opacity } }), _jsx("div", { className: "ecx-cover-inner", children: await children() })] }), undefined);
392
365
  }
366
+ case "mediaText": return shelled("mediaText", a, key, _jsxs(_Fragment, { children: [_jsx("figure", { className: "ecx-media-text-media", style: { margin: 0 }, children: a.src && _jsx("img", { src: safeUrl(a.src, ""), alt: a.alt ?? "", loading: "lazy", decoding: "async" }) }), _jsx("div", { className: "ecx-media-text-content", children: await children() })] }));
393
367
  case "pullquote":
394
- return _jsxs("figure", { className: "ecx-pullquote", children: [_jsx("blockquote", { children: _jsx("p", { children: await children() }) }), a.citation && _jsx("figcaption", { children: a.citation })] }, key);
368
+ return shelled("pullquote", a, key, _jsxs(_Fragment, { children: [_jsx("blockquote", { children: _jsx("p", { children: await children() }) }), blockCitation(a) && _jsx("figcaption", { children: blockCitation(a) })] }));
395
369
  case "accordion": {
396
370
  const sub = a.multiple === true ? ctx : { ...ctx, accordion: `ecx-acc-${key}` };
397
371
  return _jsx("div", { className: "ecx-accordion", children: await Promise.all((node.content ?? []).map((c, i) => renderNode(c, `${key}-${i}`, sub))) }, key);
@@ -432,7 +406,7 @@ async function renderNodeInner(node, key, ctx) {
432
406
  return _jsxs("details", { className: "ecx-details", name: ctx.accordion, open: a.open === true || undefined, children: [_jsx("summary", { children: a.summary || "…" }), await children()] }, key);
433
407
  case "customHtml":
434
408
  // Máy chủ đã lọc HTML khi người soạn thiếu quyền unfiltered_html (ContentSanitizer)
435
- return a.html ? _jsx("div", { className: "ecx-html", dangerouslySetInnerHTML: { __html: String(a.html) } }, key) : null;
409
+ return a.html ? createElement(blockShell("customHtml", a).tag, { key, className: blockShell("customHtml", a).className, dangerouslySetInnerHTML: { __html: String(a.html) } }) : null;
436
410
  case "socialLinks": {
437
411
  const links = (Array.isArray(a.links) ? a.links : []).filter((l) => l && typeof l.url === "string" && typeof l.service === "string" && /^[a-z0-9-]{1,30}$/.test(l.service));
438
412
  if (!links.length)
@@ -458,7 +432,7 @@ async function renderNodeInner(node, key, ctx) {
458
432
  if (!info)
459
433
  return a.url ? _jsx("p", { className: "ecx-embed-link cms-embed-link", children: _jsx("a", { href: safeUrl(a.url), target: "_blank", rel: "noopener noreferrer", children: a.caption || a.url }) }, key) : null;
460
434
  const box = info.aspect ? { position: "relative", aspectRatio: String(info.aspect) } : { position: "relative", height: info.height };
461
- return (_jsxs("figure", { className: cx("ecx-embed cms-embed", `ecx-embed-${info.provider} cms-embed-${info.provider}`), style: { maxWidth: info.maxWidth, marginLeft: info.maxWidth ? "auto" : undefined, marginRight: info.maxWidth ? "auto" : undefined }, children: [_jsx("div", { style: box, children: _jsx("iframe", { src: info.src, title: a.caption || info.title, loading: "lazy", allowFullScreen: true, referrerPolicy: "strict-origin-when-cross-origin", allow: "autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture", style: { position: "absolute", inset: 0, width: "100%", height: "100%", border: 0, borderRadius: 8 } }) }), a.caption && _jsx("figcaption", { children: a.caption })] }, key));
435
+ return shelled("embed", a, key, _jsxs(_Fragment, { children: [_jsx("div", { style: box, children: _jsx("iframe", { src: info.src, title: a.caption || info.title, loading: "lazy", allowFullScreen: true, referrerPolicy: "strict-origin-when-cross-origin", allow: "autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture", style: { position: "absolute", inset: 0, width: "100%", height: "100%", border: 0, borderRadius: 8 } }) }), a.caption && _jsx("figcaption", { children: a.caption })] }));
462
436
  }
463
437
  default: {
464
438
  if (DYNAMIC.has(node.type))
package/dist/runtime.js CHANGED
@@ -80,7 +80,7 @@ export const getActiveExtensions = cache(async (site) => {
80
80
  const s = site ?? (await getSite());
81
81
  const { plugins } = runtime();
82
82
  const defs = [];
83
- for (const slug of s.activePlugins) {
83
+ for (const slug of s.activePlugins ?? []) {
84
84
  const loader = plugins[slug];
85
85
  if (!loader)
86
86
  continue;
package/dist/types.d.ts CHANGED
@@ -244,6 +244,31 @@ export interface LayoutProps {
244
244
  /** Trang đang xem — truyền cho <EditableRegion data={data}> để vùng (và plugin thay vùng) biết trang nào. */
245
245
  data?: ResolveResult;
246
246
  }
247
+ /** Một giá trị preset: chuỗi, hoặc { label, value } để hiện tên trong Thiết kế. */
248
+ export type ThemeStyleValue = string | {
249
+ label?: string;
250
+ value: string;
251
+ };
252
+ /** Bộ phối sẵn của theme (CMS ≥ 1.23): bấm một lần là đổi màu / phông ở Thiết kế › Phong cách. */
253
+ export interface ThemeStyleVariation {
254
+ id: string;
255
+ title: string;
256
+ colors?: Record<string, string>;
257
+ fonts?: Record<string, string>;
258
+ }
259
+ export interface ThemeStyles {
260
+ colors?: Record<string, ThemeStyleValue>;
261
+ fontSizes?: Record<string, ThemeStyleValue>;
262
+ spacing?: Record<string, ThemeStyleValue>;
263
+ fonts?: Record<string, ThemeStyleValue>;
264
+ gradients?: Record<string, ThemeStyleValue>;
265
+ shadows?: Record<string, ThemeStyleValue>;
266
+ variations?: ThemeStyleVariation[];
267
+ /** Kiểu mặc định theo loại khối / phần tử (Global Styles). */
268
+ blocks?: Record<string, unknown>;
269
+ elements?: Record<string, unknown>;
270
+ [group: string]: unknown;
271
+ }
247
272
  export interface ThemeManifest {
248
273
  name: string;
249
274
  slug: string;
@@ -262,6 +287,8 @@ export interface ThemeManifest {
262
287
  options?: string[];
263
288
  section?: string;
264
289
  help?: string;
290
+ /** Ô màu trùng một màu preset (`primary`, `text`, `background`…): chỉnh ở tab Phong cách, ô ẩn khỏi Cài đặt (CMS ≥ 1.23). */
291
+ preset?: string;
265
292
  }>;
266
293
  /** Cỡ ảnh riêng của theme: { "card": { "width": 600, "height": 400, "crop": true } }. */
267
294
  imageSizes?: Record<string, {
@@ -274,11 +301,8 @@ export interface ThemeManifest {
274
301
  editing?: "code" | "hybrid" | "blocks";
275
302
  /** Vùng sửa được của theme hybrid: { header: "Đầu trang" } — vẽ bằng <EditableRegion name="header">, sửa trong Trình dựng. */
276
303
  regions?: Record<string, string>;
277
- /** Preset kiểu dáng: { colors: { primary: { label, value } | "#hex" }, fontSizes, spacing, fonts }. */
278
- styles?: Record<string, Record<string, string | {
279
- label?: string;
280
- value: string;
281
- }>>;
304
+ /** Preset kiểu dáng: { colors: { primary: { label, value } | "#hex" }, fontSizes, spacing, fonts, variations, blocks, elements }. */
305
+ styles?: ThemeStyles;
282
306
  /** Biến thể kiểu theo loại khối: { table: [{ name: "bordered", label: "%…%" }] } → class .ecx-is-<name>. */
283
307
  blockStyles?: Record<string, Array<{
284
308
  name: string;
@@ -465,6 +489,17 @@ export interface FilterMap {
465
489
  site: Site;
466
490
  data: ResolveResult;
467
491
  }) => string[] | Promise<string[]>;
492
+ /**
493
+ * Schema BreadcrumbList của khối "breadcrumbs" trong theme. Plugin SEO tự in BreadcrumbList trong @graph của nó thì trả null
494
+ * (trang chỉ có một BreadcrumbList); vẫn vẽ đường dẫn nhìn thấy.
495
+ */
496
+ "breadcrumbs.schema": (schema: Record<string, unknown> | null, ctx: {
497
+ site: Site;
498
+ items: Array<{
499
+ name: string;
500
+ href?: string;
501
+ }>;
502
+ }) => Record<string, unknown> | null | Promise<Record<string, unknown> | null>;
468
503
  /** Thêm/bớt class của thẻ <body> (vd "logged-in", "has-promo-bar") */
469
504
  "body.class": (classes: string[], ctx: {
470
505
  site: Site;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecomcx/ecomweb-theme-sdk",
3
- "version": "1.35.0",
3
+ "version": "1.37.0",
4
4
  "description": "SDK để viết theme và phần frontend của plugin cho Ecomweb",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -33,7 +33,7 @@
33
33
  "README.md"
34
34
  ],
35
35
  "dependencies": {
36
- "@ecomcx/ecomweb-content": "^1.18.0",
36
+ "@ecomcx/ecomweb-content": "^1.19.0",
37
37
  "intl-messageformat": "12.1.3"
38
38
  },
39
39
  "peerDependencies": {