@yimingliao/cms 0.0.173 → 0.0.175
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/src/client/interfaces/components/resources/post/post-card.js +46 -13
- package/dist/src/client/interfaces/components/ui/cards/resource-card/card-text-content.js +10 -5
- package/dist/src/server/infrastructure/cache/create-cache-result.js +1 -3
- package/dist/types/src/client/interfaces/components/resources/post/post-card.d.ts +5 -2
- package/dist/types/src/client/interfaces/components/resources/post/post-card.d.ts.map +1 -1
- package/dist/types/src/client/interfaces/components/ui/cards/resource-card/card-text-content.d.ts +3 -1
- package/dist/types/src/client/interfaces/components/ui/cards/resource-card/card-text-content.d.ts.map +1 -1
- package/dist/types/src/server/infrastructure/cache/create-cache-result.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -33,15 +33,37 @@ import '../../../../../domain/resources/admin/constants.js';
|
|
|
33
33
|
import 'next/image';
|
|
34
34
|
import { PostStatusBarIcons } from './post-status-bar-icons.js';
|
|
35
35
|
|
|
36
|
+
const CARD_CHILDREN_STYLES = {
|
|
37
|
+
WebkitMaskImage: "linear-gradient(to top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 75%)",
|
|
38
|
+
maskImage: "linear-gradient(to top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 75%)"
|
|
39
|
+
};
|
|
36
40
|
function createPostCard({
|
|
37
|
-
SmartImage
|
|
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
|
|
38
60
|
}) {
|
|
39
61
|
return function PostCard({
|
|
40
62
|
post,
|
|
41
|
-
//
|
|
63
|
+
// link
|
|
42
64
|
openNewTab = false,
|
|
43
65
|
anchorProps,
|
|
44
|
-
//
|
|
66
|
+
// base
|
|
45
67
|
className = ""
|
|
46
68
|
}) {
|
|
47
69
|
const { locale } = useTranslator();
|
|
@@ -49,10 +71,14 @@ function createPostCard({
|
|
|
49
71
|
const topicTitle = findTranslation(topic?.translations, locale)?.title ?? "";
|
|
50
72
|
const translation = findTranslation(post.translations, locale);
|
|
51
73
|
const { isActive, isSlugActive, index, isFeatured, isShownOnHome } = post;
|
|
74
|
+
const hasTitleFields = titleFields.length > 0;
|
|
75
|
+
const hasChildrenFields = childrenFields.length > 0;
|
|
76
|
+
const title = resolveTranslationFields(translation, titleFields);
|
|
77
|
+
const childrenRaw = resolveTranslationFields(translation, childrenFields);
|
|
52
78
|
return /* @__PURE__ */ jsx(
|
|
53
79
|
ResourceCard,
|
|
54
80
|
{
|
|
55
|
-
className: cn(className, "
|
|
81
|
+
className: cn(className, "w-72!"),
|
|
56
82
|
href: `${PATHS.resources.post.path(topic?.slug)}/${post.id}`,
|
|
57
83
|
openNewTab,
|
|
58
84
|
anchorProps,
|
|
@@ -70,20 +96,19 @@ function createPostCard({
|
|
|
70
96
|
)
|
|
71
97
|
},
|
|
72
98
|
cardTextContentProps: {
|
|
73
|
-
title
|
|
99
|
+
title,
|
|
74
100
|
children: /* @__PURE__ */ jsx(
|
|
75
101
|
"div",
|
|
76
102
|
{
|
|
77
103
|
className: "line-clamp-2 h-10 text-sm whitespace-normal",
|
|
78
|
-
style:
|
|
79
|
-
|
|
80
|
-
maskImage: "linear-gradient(to top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 75%)"
|
|
81
|
-
},
|
|
82
|
-
children: translation?.summary || translation?.description || translation.content && /* @__PURE__ */ jsx(HtmlDisplay, { html: translation.content, textOnly: true })
|
|
104
|
+
style: CARD_CHILDREN_STYLES,
|
|
105
|
+
children: /* @__PURE__ */ jsx(HtmlDisplay, { html: childrenRaw ?? "", textOnly: true })
|
|
83
106
|
}
|
|
84
|
-
)
|
|
107
|
+
),
|
|
108
|
+
hasTitleFields,
|
|
109
|
+
hasChildrenFields
|
|
85
110
|
},
|
|
86
|
-
children: /* @__PURE__ */ jsx(
|
|
111
|
+
children: hasCoverImageFields && /* @__PURE__ */ jsx(
|
|
87
112
|
"div",
|
|
88
113
|
{
|
|
89
114
|
className: cn(
|
|
@@ -100,7 +125,7 @@ function createPostCard({
|
|
|
100
125
|
width: 256,
|
|
101
126
|
height: 256,
|
|
102
127
|
fill: false,
|
|
103
|
-
className: "overflow-hidden rounded-xl"
|
|
128
|
+
className: "size-64 overflow-hidden rounded-xl"
|
|
104
129
|
}
|
|
105
130
|
)
|
|
106
131
|
}
|
|
@@ -109,5 +134,13 @@ function createPostCard({
|
|
|
109
134
|
);
|
|
110
135
|
};
|
|
111
136
|
}
|
|
137
|
+
function resolveTranslationFields(translation, fields) {
|
|
138
|
+
if (!translation || !fields) return void 0;
|
|
139
|
+
for (const field of fields) {
|
|
140
|
+
const value = translation[field];
|
|
141
|
+
if (typeof value === "string" && value !== "") return value;
|
|
142
|
+
}
|
|
143
|
+
return void 0;
|
|
144
|
+
}
|
|
112
145
|
|
|
113
146
|
export { createPostCard };
|
|
@@ -21,7 +21,12 @@ import 'sonner';
|
|
|
21
21
|
import '@radix-ui/react-tabs';
|
|
22
22
|
import '@radix-ui/react-tooltip';
|
|
23
23
|
|
|
24
|
-
function CardTextContent({
|
|
24
|
+
function CardTextContent({
|
|
25
|
+
title,
|
|
26
|
+
children,
|
|
27
|
+
hasTitleFields = true,
|
|
28
|
+
hasChildrenFields = true
|
|
29
|
+
}) {
|
|
25
30
|
return /* @__PURE__ */ jsx("div", { className: cn("relative z-10 h-fit", "mt-auto", "bg-background"), children: /* @__PURE__ */ jsxs(
|
|
26
31
|
"div",
|
|
27
32
|
{
|
|
@@ -30,10 +35,10 @@ function CardTextContent({ title, children }) {
|
|
|
30
35
|
"bg-background group-hover:bg-accent/50 transition"
|
|
31
36
|
),
|
|
32
37
|
children: [
|
|
33
|
-
/* @__PURE__ */ jsx(Separator, {}),
|
|
34
|
-
/* @__PURE__ */ jsx("div", { className: cn("h-10", "px-4", "flex items-center"), children: /* @__PURE__ */ jsx("p", { className: "truncate", children: title }) }),
|
|
35
|
-
children && /* @__PURE__ */ jsx(Separator, {}),
|
|
36
|
-
children && /* @__PURE__ */ jsx("div", { className: cn("px-4 py-2", "text-sm"), children })
|
|
38
|
+
hasTitleFields && /* @__PURE__ */ jsx(Separator, {}),
|
|
39
|
+
hasTitleFields && /* @__PURE__ */ jsx("div", { className: cn("h-10", "px-4", "flex items-center"), children: /* @__PURE__ */ jsx("p", { className: "truncate", children: title }) }),
|
|
40
|
+
hasChildrenFields && children && /* @__PURE__ */ jsx(Separator, {}),
|
|
41
|
+
hasChildrenFields && children && /* @__PURE__ */ jsx("div", { className: cn("px-4 py-2", "text-sm"), children })
|
|
37
42
|
]
|
|
38
43
|
}
|
|
39
44
|
) });
|
|
@@ -23,9 +23,7 @@ function createCacheResult(cache, logger) {
|
|
|
23
23
|
const data = await load();
|
|
24
24
|
if (data !== void 0) {
|
|
25
25
|
const shouldCache = typeof data === "object" && data !== null && "data" in data && typeof data.data === "object" && data.data !== null && "items" in data.data && Array.isArray(data.data.items) && data.data.items.length > 0;
|
|
26
|
-
if (shouldCache)
|
|
27
|
-
await cache.set(key, data, ttl);
|
|
28
|
-
}
|
|
26
|
+
if (shouldCache) await cache.set(key, data, ttl);
|
|
29
27
|
}
|
|
30
28
|
return data;
|
|
31
29
|
} catch (error) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PostListCard } from "../../../../../domain";
|
|
1
|
+
import type { PostListCard, PostTranslation } from "../../../../../domain";
|
|
2
2
|
import type { createSmartImage } from "../../ui";
|
|
3
3
|
import type { ComponentProps } from "react";
|
|
4
4
|
interface PostCardProps {
|
|
@@ -7,8 +7,11 @@ interface PostCardProps {
|
|
|
7
7
|
openNewTab?: boolean;
|
|
8
8
|
anchorProps?: ComponentProps<"a"> | undefined;
|
|
9
9
|
}
|
|
10
|
-
export declare function createPostCard({ SmartImage, }: {
|
|
10
|
+
export declare function createPostCard({ SmartImage, titleFields, childrenFields, hasCoverImageFields, }: {
|
|
11
11
|
SmartImage: ReturnType<typeof createSmartImage>;
|
|
12
|
+
titleFields?: (keyof PostTranslation)[];
|
|
13
|
+
childrenFields?: (keyof PostTranslation)[];
|
|
14
|
+
hasCoverImageFields?: boolean;
|
|
12
15
|
}): ({ post, openNewTab, anchorProps, className, }: PostCardProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
16
|
export {};
|
|
14
17
|
//# 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,MAAM,uBAAuB,CAAC;
|
|
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"}
|
package/dist/types/src/client/interfaces/components/ui/cards/resource-card/card-text-content.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import type { ReactNode } from "react";
|
|
|
2
2
|
export interface CardTextContentProps {
|
|
3
3
|
title?: ReactNode;
|
|
4
4
|
children?: ReactNode;
|
|
5
|
+
hasTitleFields?: boolean;
|
|
6
|
+
hasChildrenFields?: boolean;
|
|
5
7
|
}
|
|
6
|
-
export declare function CardTextContent({ title, children }: CardTextContentProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function CardTextContent({ title, children, hasTitleFields, hasChildrenFields, }: CardTextContentProps): import("react/jsx-runtime").JSX.Element;
|
|
7
9
|
//# sourceMappingURL=card-text-content.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card-text-content.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/client/interfaces/components/ui/cards/resource-card/card-text-content.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"card-text-content.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/client/interfaces/components/ui/cards/resource-card/card-text-content.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,QAAQ,EACR,cAAqB,EACrB,iBAAwB,GACzB,EAAE,oBAAoB,2CA2BtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-cache-result.d.ts","sourceRoot":"","sources":["../../../../../../src/server/infrastructure/cache/create-cache-result.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAI5E,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,GAAG,EAAE,WAAW,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC;CACxB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,IAClC,CAAC,EAAE,6BAIlC,kBAAkB,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"create-cache-result.d.ts","sourceRoot":"","sources":["../../../../../../src/server/infrastructure/cache/create-cache-result.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAI5E,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,GAAG,EAAE,WAAW,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC;CACxB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,IAClC,CAAC,EAAE,6BAIlC,kBAAkB,CAAC,CAAC,CAAC,gBAgDzB"}
|