@yimingliao/cms 0.0.176 → 0.0.177

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.
@@ -39,24 +39,7 @@ const CARD_CHILDREN_STYLES = {
39
39
  };
40
40
  function createPostCard({
41
41
  SmartImage,
42
- titleFields = ["title"],
43
- childrenFields = [
44
- "summary",
45
- "description",
46
- "content",
47
- "content",
48
- "text1",
49
- "text2",
50
- "text3",
51
- "text4",
52
- "text5",
53
- "text6",
54
- "text7",
55
- "text8",
56
- "text9",
57
- "text10"
58
- ],
59
- hasCoverImageFields = true
42
+ strategies
60
43
  }) {
61
44
  return function PostCard({
62
45
  post,
@@ -71,14 +54,17 @@ function createPostCard({
71
54
  const topicTitle = findTranslation(topic?.translations, locale)?.title ?? "";
72
55
  const translation = findTranslation(post.translations, locale);
73
56
  const { isActive, isSlugActive, index, isFeatured, isShownOnHome } = post;
74
- const hasTitleFields = titleFields.length > 0;
75
- const hasChildrenFields = childrenFields.length > 0;
57
+ const {
58
+ titleFields = ["title"],
59
+ childrenFields = ["content"],
60
+ hasCoverImage = true
61
+ } = strategies?.[post.type] ?? {};
76
62
  const title = resolveTranslationFields(translation, titleFields);
77
63
  const childrenRaw = resolveTranslationFields(translation, childrenFields);
78
64
  return /* @__PURE__ */ jsx(
79
65
  ResourceCard,
80
66
  {
81
- className: cn(className, hasCoverImageFields ? "size-72!" : "w-72!"),
67
+ className: cn(className, hasCoverImage ? "size-72!" : "w-72!"),
82
68
  href: `${PATHS.resources.post.path(topic?.slug)}/${post.id}`,
83
69
  openNewTab,
84
70
  anchorProps,
@@ -97,7 +83,7 @@ function createPostCard({
97
83
  },
98
84
  cardTextContentProps: {
99
85
  title,
100
- children: /* @__PURE__ */ jsx(
86
+ children: childrenRaw && /* @__PURE__ */ jsx(
101
87
  "div",
102
88
  {
103
89
  className: "line-clamp-2 h-10 text-sm whitespace-normal",
@@ -105,10 +91,10 @@ function createPostCard({
105
91
  children: /* @__PURE__ */ jsx(HtmlDisplay, { html: childrenRaw ?? "", textOnly: true })
106
92
  }
107
93
  ),
108
- hasTitleFields,
109
- hasChildrenFields
94
+ hasTitleFields: titleFields.length > 0,
95
+ hasChildrenFields: childrenFields.length > 0
110
96
  },
111
- children: hasCoverImageFields && /* @__PURE__ */ jsx(
97
+ children: hasCoverImage && /* @__PURE__ */ jsx(
112
98
  "div",
113
99
  {
114
100
  className: cn(
@@ -125,7 +111,7 @@ function createPostCard({
125
111
  width: 256,
126
112
  height: 256,
127
113
  fill: false,
128
- className: "size-64 overflow-hidden rounded-xl"
114
+ className: "overflow-hidden rounded-xl"
129
115
  }
130
116
  )
131
117
  }
@@ -1,17 +1,20 @@
1
1
  import type { PostListCard, PostTranslation } from "../../../../../domain";
2
2
  import type { createSmartImage } from "../../ui";
3
3
  import type { ComponentProps } from "react";
4
+ type PostCardStrategy = {
5
+ titleFields?: (keyof PostTranslation)[];
6
+ childrenFields?: (keyof PostTranslation)[];
7
+ hasCoverImage?: boolean;
8
+ };
4
9
  interface PostCardProps {
5
10
  post: PostListCard;
6
11
  className?: string;
7
12
  openNewTab?: boolean;
8
13
  anchorProps?: ComponentProps<"a"> | undefined;
9
14
  }
10
- export declare function createPostCard({ SmartImage, titleFields, childrenFields, hasCoverImageFields, }: {
15
+ export declare function createPostCard({ SmartImage, strategies, }: {
11
16
  SmartImage: ReturnType<typeof createSmartImage>;
12
- titleFields?: (keyof PostTranslation)[];
13
- childrenFields?: (keyof PostTranslation)[];
14
- hasCoverImageFields?: boolean;
17
+ strategies?: Record<string, PostCardStrategy>;
15
18
  }): ({ post, openNewTab, anchorProps, className, }: PostCardProps) => import("react/jsx-runtime").JSX.Element;
16
19
  export {};
17
20
  //# sourceMappingURL=post-card.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"post-card.d.ts","sourceRoot":"","sources":["../../../../../../../../src/client/interfaces/components/resources/post/post-card.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAe5C,UAAU,aAAa;IACrB,IAAI,EAAE,YAAY,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,cAAc,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;CAC/C;AAED,wBAAgB,cAAc,CAAC,EAC7B,UAAU,EACV,WAAuB,EACvB,cAeC,EACD,mBAA0B,GAC3B,EAAE;IACD,UAAU,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;IAChD,WAAW,CAAC,EAAE,CAAC,MAAM,eAAe,CAAC,EAAE,CAAC;IACxC,cAAc,CAAC,EAAE,CAAC,MAAM,eAAe,CAAC,EAAE,CAAC;IAC3C,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,IAC0B,+CAOtB,aAAa,6CAwEjB"}
1
+ {"version":3,"file":"post-card.d.ts","sourceRoot":"","sources":["../../../../../../../../src/client/interfaces/components/resources/post/post-card.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAe5C,KAAK,gBAAgB,GAAG;IACtB,WAAW,CAAC,EAAE,CAAC,MAAM,eAAe,CAAC,EAAE,CAAC;IACxC,cAAc,CAAC,EAAE,CAAC,MAAM,eAAe,CAAC,EAAE,CAAC;IAC3C,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,UAAU,aAAa;IACrB,IAAI,EAAE,YAAY,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,cAAc,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;CAC/C;AAED,wBAAgB,cAAc,CAAC,EAC7B,UAAU,EACV,UAAU,GACX,EAAE;IACD,UAAU,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAC/C,IAC0B,+CAOtB,aAAa,6CA4EjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yimingliao/cms",
3
- "version": "0.0.176",
3
+ "version": "0.0.177",
4
4
  "author": "Yiming Liao",
5
5
  "license": "MIT",
6
6
  "type": "module",