@roottale/cms-renderer-next 0.58.0 → 0.60.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/dist/server.js CHANGED
@@ -1615,11 +1615,19 @@ function renderPostCta(cta) {
1615
1615
  )
1616
1616
  ] });
1617
1617
  }
1618
- function renderRelatedPosts(posts, href, title) {
1618
+ function relatedCardsFromPosts(posts, href) {
1619
+ return posts.map((post) => ({
1620
+ id: post.id,
1621
+ title: post.title,
1622
+ href: href(post),
1623
+ featuredImageUrl: post.featuredImageUrl
1624
+ }));
1625
+ }
1626
+ function renderRelatedPosts(posts, title) {
1619
1627
  if (posts.length === 0) return null;
1620
1628
  return /* @__PURE__ */ jsxs12("nav", { "data-roottale-cms": "related", className: "rt-cms-related", "aria-label": title, children: [
1621
1629
  /* @__PURE__ */ jsx17("h2", { className: "rt-cms-related-title", children: title }),
1622
- /* @__PURE__ */ jsx17("ul", { className: "rt-cms-related-list", children: posts.map((post) => /* @__PURE__ */ jsx17("li", { className: "rt-cms-related-item", children: /* @__PURE__ */ jsxs12("a", { className: "rt-cms-related-link", href: href(post), children: [
1630
+ /* @__PURE__ */ jsx17("ul", { className: "rt-cms-related-list", children: posts.map((post) => /* @__PURE__ */ jsx17("li", { className: "rt-cms-related-item", children: /* @__PURE__ */ jsxs12("a", { className: "rt-cms-related-link", href: post.href, children: [
1623
1631
  post.featuredImageUrl ? /* @__PURE__ */ jsx17(
1624
1632
  "img",
1625
1633
  {
@@ -1652,6 +1660,14 @@ function RootTaleFaqJsonLd({
1652
1660
 
1653
1661
  // src/server/blog-post.tsx
1654
1662
  import { jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
1663
+ function editorPickedRelatedCards(post) {
1664
+ return (post.relatedPosts ?? []).map((item) => ({
1665
+ id: item.id,
1666
+ title: item.title,
1667
+ href: item.path ?? `/blog/${item.slug}`,
1668
+ featuredImageUrl: item.featuredImageUrl
1669
+ }));
1670
+ }
1655
1671
  async function fetchRelatedPostsFailSoft(input) {
1656
1672
  if (input.count <= 0) return [];
1657
1673
  const candidates = await fetchPosts3({
@@ -1698,11 +1714,6 @@ function readEditorialReview(metaJson) {
1698
1714
  }
1699
1715
  return { reviewerName: value.reviewerName, reviewedAt: value.reviewedAt };
1700
1716
  }
1701
- function authorImageRadiusCss(radius) {
1702
- if (radius === "circle") return "999px";
1703
- if (radius === "rounded") return "0.875rem";
1704
- return "0";
1705
- }
1706
1717
  async function lookupPost(input) {
1707
1718
  if (input.previewToken) {
1708
1719
  try {
@@ -1775,8 +1786,9 @@ async function RootTaleBlogPost(props) {
1775
1786
  });
1776
1787
  const toc = display.showTableOfContents ? extractToc(post.bodyJson) : [];
1777
1788
  const renderDoc = toc.length > 0 ? attachHeadingIds(post.bodyJson, toc) : post.bodyJson;
1778
- const [related, internalLinkIndex, footerPattern] = await Promise.all([
1779
- fetchRelatedPostsFailSoft({
1789
+ const editorPicked = editorPickedRelatedCards(post);
1790
+ const [autoRelated, internalLinkIndex, footerPattern] = await Promise.all([
1791
+ editorPicked.length > 0 ? Promise.resolve([]) : fetchRelatedPostsFailSoft({
1780
1792
  post,
1781
1793
  apiKey,
1782
1794
  baseUrl,
@@ -1804,8 +1816,7 @@ async function RootTaleBlogPost(props) {
1804
1816
  const authorImageUrl = post.authorImageUrl;
1805
1817
  const authorImageAlt = `${authorName ?? ""} \uD504\uB85C\uD544 \uC0AC\uC9C4`.trim();
1806
1818
  const authorImageStyle = {
1807
- borderRadius: authorImageRadiusCss(display.authorProfileImageRadius),
1808
- objectPosition: `${display.authorProfileImagePositionX}% ${display.authorProfileImagePositionY}%`
1819
+ objectPosition: `${post.authorImagePositionX ?? display.authorProfileImagePositionX}% ${post.authorImagePositionY ?? display.authorProfileImagePositionY}%`
1809
1820
  };
1810
1821
  const showAuthorCard = display.showAuthorCard && Boolean(authorName);
1811
1822
  const editorialReview = readEditorialReview(post.metaJson);
@@ -1894,6 +1905,7 @@ async function RootTaleBlogPost(props) {
1894
1905
  }
1895
1906
  ),
1896
1907
  renderPostPattern(footerPattern, POST_FOOTER_PATTERN_SLOT2, { apiKey, baseUrl }),
1908
+ footerPattern ? null : renderPostCta(blogSettings.postCta),
1897
1909
  showAuthorCard && authorName ? /* @__PURE__ */ jsxs13("section", { className: "rt-cms-author-card", "aria-label": "\uC791\uC131\uC790", children: [
1898
1910
  authorImageUrl ? /* @__PURE__ */ jsx18(
1899
1911
  "img",
@@ -1911,8 +1923,10 @@ async function RootTaleBlogPost(props) {
1911
1923
  authorBio ? /* @__PURE__ */ jsx18("p", { className: "rt-cms-author-card__description", children: authorBio }) : null
1912
1924
  ] })
1913
1925
  ] }) : null,
1914
- renderRelatedPosts(related, relatedHref, relatedPostsTitle),
1915
- renderPostCta(blogSettings.postCta),
1926
+ renderRelatedPosts(
1927
+ editorPicked.length > 0 ? editorPicked : relatedCardsFromPosts(autoRelated, relatedHref),
1928
+ relatedPostsTitle
1929
+ ),
1916
1930
  renderFaqJsonLd(post.bodyJson)
1917
1931
  ]
1918
1932
  }