@rxdrag/website-lib-core 0.0.127 → 0.0.129
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/README.md +1 -1
- package/index.ts +1 -1
- package/package.json +4 -4
- package/src/astro/animation.ts +146 -146
- package/src/astro/background.ts +82 -86
- package/src/astro/base.ts +7 -0
- package/src/astro/business.ts +13 -0
- package/src/astro/grid/consts.ts +80 -80
- package/src/astro/grid/index.ts +2 -2
- package/src/astro/grid/types.ts +35 -35
- package/src/astro/image.ts +239 -239
- package/src/astro/index.ts +12 -10
- package/src/astro/link.ts +20 -21
- package/src/astro/media.ts +123 -123
- package/src/astro/nav.ts +13 -13
- package/src/astro/section/index.ts +7 -12
- package/src/component-logic/index.ts +1 -1
- package/src/component-logic/link-client.ts +32 -32
- package/src/component-logic/link.ts +61 -61
- package/src/design-tokens.ts +160 -160
- package/src/entify/Entify.ts +111 -101
- package/src/entify/IEntify.ts +157 -177
- package/src/entify/index.ts +4 -4
- package/src/entify/lib/collectCategoryIds.ts +20 -20
- package/src/entify/lib/fulltextSearch.ts +63 -62
- package/src/entify/lib/langFields.ts +14 -14
- package/src/entify/lib/listToTree.ts +23 -23
- package/src/entify/lib/newAvatarQueryOptions.ts +4 -4
- package/src/entify/lib/newOgImageQueryOptions.ts +5 -5
- package/src/entify/lib/newQueryPostOptions.ts +42 -45
- package/src/entify/lib/newQueryProductOptions.ts +96 -98
- package/src/entify/lib/newQueryProductsMediaOptions.ts +28 -28
- package/src/entify/lib/queryAllProducts.ts +40 -40
- package/src/entify/lib/queryBulletin.ts +28 -16
- package/src/entify/lib/queryEntityList.ts +41 -41
- package/src/entify/lib/queryFeaturedProducts.ts +69 -68
- package/src/entify/lib/queryLangs.ts +36 -60
- package/src/entify/lib/queryLatestPosts.ts +92 -91
- package/src/entify/lib/queryOneEntity.ts +63 -63
- package/src/entify/lib/queryOneMedia.ts +27 -27
- package/src/entify/lib/queryOnePostById.ts +21 -21
- package/src/entify/lib/queryOnePostBySlug.ts +40 -39
- package/src/entify/lib/queryOnePostCategoryBySlug.ts +35 -35
- package/src/entify/lib/queryOneProductById.ts +20 -20
- package/src/entify/lib/queryOneProductBySlug.ts +53 -52
- package/src/entify/lib/queryOneProductCategoryBySlug.ts +50 -49
- package/src/entify/lib/queryOneTheme.ts +54 -72
- package/src/entify/lib/queryOneUser.ts +38 -38
- package/src/entify/lib/queryPostCategories.ts +67 -67
- package/src/entify/lib/queryPostSlugs.ts +37 -37
- package/src/entify/lib/queryPosts.ts +175 -174
- package/src/entify/lib/queryProductCategories.ts +59 -59
- package/src/entify/lib/queryProducts.ts +145 -144
- package/src/entify/lib/queryProductsInMenu.ts +45 -45
- package/src/entify/lib/queryTagCategories.ts +58 -58
- package/src/entify/lib/queryTags.ts +57 -57
- package/src/entify/lib/queryUserIds.ts +24 -24
- package/src/entify/lib/queryUserPosts.ts +80 -79
- package/src/entify/lib/queryWebSiteSettings.ts +28 -28
- package/src/entify/lib/queryWebsite.ts +43 -43
- package/src/entify/lib/sendEmail.ts +7 -7
- package/src/entify/lib/toQueryOptions.ts +19 -19
- package/src/entify/lib/upsertEntity.ts +8 -8
- package/src/entify/types/index.ts +1 -1
- package/src/entify/types/utils.ts +11 -6
- package/src/entify/types/variables.ts +0 -1
- package/src/entify/view-model/funcs.ts +230 -230
- package/src/entify/view-model/index.ts +1 -1
- package/src/entify/view-model/models.ts +135 -135
- package/src/global.d.ts +7 -7
- package/src/index.ts +8 -8
- package/src/lib/formatDate.ts +15 -15
- package/src/lib/index.ts +3 -3
- package/src/lib/pagination.ts +114 -114
- package/src/lib/utils.ts +135 -135
- package/src/react/components/Analytics/eventHandlers.ts +173 -173
- package/src/react/components/Analytics/index.tsx +21 -21
- package/src/react/components/Analytics/singleton.ts +214 -214
- package/src/react/components/Analytics/tracking.ts +221 -221
- package/src/react/components/Analytics/types.ts +60 -60
- package/src/react/components/Analytics/utils.ts +95 -95
- package/src/react/components/AttachmentIcon/index.tsx +53 -53
- package/src/react/components/BackgroundHlsVideoPlayer.tsx +97 -97
- package/src/react/components/BackgroundVideoPlayer.tsx +32 -32
- package/src/react/components/Bulletin.tsx +30 -30
- package/src/react/components/ContactForm/ContactForm.tsx +289 -289
- package/src/react/components/ContactForm/Input.tsx +48 -48
- package/src/react/components/ContactForm/Input2.tsx +59 -59
- package/src/react/components/ContactForm/Submit.tsx +48 -48
- package/src/react/components/ContactForm/TelInput.tsx +215 -215
- package/src/react/components/ContactForm/Textarea.tsx +48 -48
- package/src/react/components/ContactForm/Textarea2.tsx +89 -89
- package/src/react/components/ContactForm/funcs.ts +64 -64
- package/src/react/components/ContactForm/index.ts +7 -7
- package/src/react/components/ContactForm/types.ts +68 -68
- package/src/react/components/GoogleConsent/CookieItemPanel.tsx +80 -80
- package/src/react/components/GoogleConsent/CumtomizedModal.tsx +148 -148
- package/src/react/components/GoogleConsent/GoogleConsent.tsx +100 -100
- package/src/react/components/GoogleConsent/gtags.ts +67 -67
- package/src/react/components/GoogleConsent/index.ts +2 -2
- package/src/react/components/GoogleConsent/types.ts +18 -18
- package/src/react/components/GoogleConsent//345/217/202/350/200/203.md +4 -4
- package/src/react/components/Icon/index.tsx +19 -19
- package/src/react/components/Medias/MainMedia.tsx +257 -257
- package/src/react/components/Medias/Thumbnail.tsx +62 -62
- package/src/react/components/Medias/VideoPlayer.tsx +114 -114
- package/src/react/components/Medias/index.tsx +271 -271
- package/src/react/components/ProductCard/ProductCard.tsx +24 -24
- package/src/react/components/ProductCard/ProductCta/index.tsx +28 -28
- package/src/react/components/ProductCard/ProductCta/style.css +3 -3
- package/src/react/components/ProductCard/ProductDescription/index.tsx +12 -12
- package/src/react/components/ProductCard/ProductDescription/style.css +5 -5
- package/src/react/components/ProductCard/ProductMedia/index.tsx +35 -35
- package/src/react/components/ProductCard/ProductMedia/style.css +5 -5
- package/src/react/components/ProductCard/ProductTitle/index.tsx +7 -7
- package/src/react/components/ProductCard/ProductTitle/style.css +3 -3
- package/src/react/components/ProductCard/ProductView.tsx +36 -36
- package/src/react/components/ProductCard/index.ts +4 -4
- package/src/react/components/ProductCard/useQueryProduct.ts +32 -32
- package/src/react/components/ReactModalTrigger.tsx +28 -28
- package/src/react/components/ReactVideoPlayer.tsx +29 -52
- package/src/react/components/RichTextOutline/index.tsx +75 -75
- package/src/react/components/RichTextOutline/useAnchorScroll.ts +23 -23
- package/src/react/components/Scroller.tsx +39 -39
- package/src/react/components/SearchInput.tsx +21 -21
- package/src/react/components/Share/index.tsx +86 -86
- package/src/react/components/Share/socials.tsx +79 -77
- package/src/react/components/Share//350/265/204/346/226/231.md +7 -7
- package/src/react/components/ToTop.tsx +72 -72
- package/src/react/components/VideoPlayIcon.tsx +43 -0
- package/src/react/components/all.ts +38 -38
- package/src/react/components/index.ts +16 -16
- package/src/robots.ts +4 -4
- package/src/entify/lib/newPageMetaOptions.ts +0 -18
- package/src/entify/lib/newQueryPageOptions.ts +0 -14
- package/src/entify/lib/queryOneIcon.ts +0 -27
- package/src/entify/lib/queryPageBySlug.ts +0 -43
- package/src/entify/lib/queryPageByType.ts +0 -44
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PostCategory,
|
|
3
|
-
PostCategoryBoolExp,
|
|
4
|
-
PostCategoryOrderBy,
|
|
5
|
-
PostCategoryDistinctExp,
|
|
6
|
-
PostCategoryFields,
|
|
7
|
-
PostCategoryQueryOptions,
|
|
8
|
-
ProductFields,
|
|
9
|
-
PublishableStatus,
|
|
10
|
-
PostQueryOptions,
|
|
11
|
-
PostFields,
|
|
12
|
-
} from "@rxdrag/rxcms-models";
|
|
13
|
-
import { queryEntityList } from "./queryEntityList";
|
|
14
|
-
import { ListResult } from "@rxdrag/entify-lib";
|
|
15
|
-
import { EnvVariables } from "../types";
|
|
16
|
-
import { TPostCategory } from "../view-model";
|
|
17
|
-
import { listToTree } from "./listToTree";
|
|
18
|
-
|
|
19
|
-
export async function queryPostCategories(envVariables: EnvVariables) {
|
|
20
|
-
const result = await queryEntityList<
|
|
21
|
-
PostCategory,
|
|
22
|
-
PostCategoryBoolExp,
|
|
23
|
-
PostCategoryOrderBy,
|
|
24
|
-
PostCategoryDistinctExp
|
|
25
|
-
>(
|
|
26
|
-
new PostCategoryQueryOptions(
|
|
27
|
-
[
|
|
28
|
-
PostCategoryFields.id,
|
|
29
|
-
PostCategoryFields.name,
|
|
30
|
-
PostCategoryFields.slug,
|
|
31
|
-
PostCategoryFields.description,
|
|
32
|
-
],
|
|
33
|
-
{
|
|
34
|
-
where: {
|
|
35
|
-
lang: {
|
|
36
|
-
abbr: {
|
|
37
|
-
_eq:
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
orderBy: [{ [PostCategoryFields.seqValue]: "asc" }],
|
|
42
|
-
}
|
|
43
|
-
)
|
|
44
|
-
.parent()
|
|
45
|
-
.posts(
|
|
46
|
-
new PostQueryOptions(
|
|
47
|
-
[PostFields.id, PostFields.title, PostFields.slug],
|
|
48
|
-
{
|
|
49
|
-
where: {
|
|
50
|
-
[PostFields.status]: {
|
|
51
|
-
_eq: PublishableStatus.published,
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
orderBy: [{ [ProductFields.seqValue]: "asc" }],
|
|
55
|
-
}
|
|
56
|
-
)
|
|
57
|
-
),
|
|
58
|
-
envVariables
|
|
59
|
-
);
|
|
60
|
-
const typedResult = result as ListResult<TPostCategory> | undefined;
|
|
61
|
-
|
|
62
|
-
if (!typedResult) {
|
|
63
|
-
return undefined;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return listToTree(typedResult.items || []);
|
|
67
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
PostCategory,
|
|
3
|
+
PostCategoryBoolExp,
|
|
4
|
+
PostCategoryOrderBy,
|
|
5
|
+
PostCategoryDistinctExp,
|
|
6
|
+
PostCategoryFields,
|
|
7
|
+
PostCategoryQueryOptions,
|
|
8
|
+
ProductFields,
|
|
9
|
+
PublishableStatus,
|
|
10
|
+
PostQueryOptions,
|
|
11
|
+
PostFields,
|
|
12
|
+
} from "@rxdrag/rxcms-models";
|
|
13
|
+
import { queryEntityList } from "./queryEntityList";
|
|
14
|
+
import { ListResult } from "@rxdrag/entify-lib";
|
|
15
|
+
import { EnvVariables } from "../types";
|
|
16
|
+
import { TPostCategory } from "../view-model";
|
|
17
|
+
import { listToTree } from "./listToTree";
|
|
18
|
+
|
|
19
|
+
export async function queryPostCategories(envVariables: EnvVariables, langAbbr: string) {
|
|
20
|
+
const result = await queryEntityList<
|
|
21
|
+
PostCategory,
|
|
22
|
+
PostCategoryBoolExp,
|
|
23
|
+
PostCategoryOrderBy,
|
|
24
|
+
PostCategoryDistinctExp
|
|
25
|
+
>(
|
|
26
|
+
new PostCategoryQueryOptions(
|
|
27
|
+
[
|
|
28
|
+
PostCategoryFields.id,
|
|
29
|
+
PostCategoryFields.name,
|
|
30
|
+
PostCategoryFields.slug,
|
|
31
|
+
PostCategoryFields.description,
|
|
32
|
+
],
|
|
33
|
+
{
|
|
34
|
+
where: {
|
|
35
|
+
lang: {
|
|
36
|
+
abbr: {
|
|
37
|
+
_eq: langAbbr,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
orderBy: [{ [PostCategoryFields.seqValue]: "asc" }],
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
.parent()
|
|
45
|
+
.posts(
|
|
46
|
+
new PostQueryOptions(
|
|
47
|
+
[PostFields.id, PostFields.title, PostFields.slug],
|
|
48
|
+
{
|
|
49
|
+
where: {
|
|
50
|
+
[PostFields.status]: {
|
|
51
|
+
_eq: PublishableStatus.published,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
orderBy: [{ [ProductFields.seqValue]: "asc" }],
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
),
|
|
58
|
+
envVariables
|
|
59
|
+
);
|
|
60
|
+
const typedResult = result as ListResult<TPostCategory> | undefined;
|
|
61
|
+
|
|
62
|
+
if (!typedResult) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return listToTree(typedResult.items || []);
|
|
67
|
+
}
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Post,
|
|
3
|
-
PostBoolExp,
|
|
4
|
-
PostDistinctExp,
|
|
5
|
-
PostFields,
|
|
6
|
-
PostOrderBy,
|
|
7
|
-
PostQueryOptions,
|
|
8
|
-
PublishableStatus,
|
|
9
|
-
} from "@rxdrag/rxcms-models";
|
|
10
|
-
import { EnvVariables } from "../types";
|
|
11
|
-
import { ListResult } from "@rxdrag/entify-lib";
|
|
12
|
-
import { TPost } from "../view-model";
|
|
13
|
-
import { queryEntityList } from "./queryEntityList";
|
|
14
|
-
|
|
15
|
-
export async function queryPostSlugs(envVariables: EnvVariables) {
|
|
16
|
-
const queryOptions = new PostQueryOptions([PostFields.id, PostFields.slug], {
|
|
17
|
-
where: {
|
|
18
|
-
[PostFields.status]: {
|
|
19
|
-
_eq: PublishableStatus.published,
|
|
20
|
-
},
|
|
21
|
-
lang: {
|
|
22
|
-
abbr: {
|
|
23
|
-
_eq:
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
orderBy: [{ [PostFields.seqValue]: "asc" }],
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const result = await queryEntityList<
|
|
31
|
-
Post,
|
|
32
|
-
PostBoolExp,
|
|
33
|
-
PostOrderBy,
|
|
34
|
-
PostDistinctExp
|
|
35
|
-
>(queryOptions, envVariables);
|
|
36
|
-
return result as ListResult<TPost> | undefined;
|
|
37
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
Post,
|
|
3
|
+
PostBoolExp,
|
|
4
|
+
PostDistinctExp,
|
|
5
|
+
PostFields,
|
|
6
|
+
PostOrderBy,
|
|
7
|
+
PostQueryOptions,
|
|
8
|
+
PublishableStatus,
|
|
9
|
+
} from "@rxdrag/rxcms-models";
|
|
10
|
+
import { EnvVariables } from "../types";
|
|
11
|
+
import { ListResult } from "@rxdrag/entify-lib";
|
|
12
|
+
import { TPost } from "../view-model";
|
|
13
|
+
import { queryEntityList } from "./queryEntityList";
|
|
14
|
+
|
|
15
|
+
export async function queryPostSlugs(envVariables: EnvVariables, langAbbr: string) {
|
|
16
|
+
const queryOptions = new PostQueryOptions([PostFields.id, PostFields.slug], {
|
|
17
|
+
where: {
|
|
18
|
+
[PostFields.status]: {
|
|
19
|
+
_eq: PublishableStatus.published,
|
|
20
|
+
},
|
|
21
|
+
lang: {
|
|
22
|
+
abbr: {
|
|
23
|
+
_eq: langAbbr,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
orderBy: [{ [PostFields.seqValue]: "asc" }],
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const result = await queryEntityList<
|
|
31
|
+
Post,
|
|
32
|
+
PostBoolExp,
|
|
33
|
+
PostOrderBy,
|
|
34
|
+
PostDistinctExp
|
|
35
|
+
>(queryOptions, envVariables);
|
|
36
|
+
return result as ListResult<TPost> | undefined;
|
|
37
|
+
}
|
|
@@ -1,174 +1,175 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Post,
|
|
3
|
-
PostBoolExp,
|
|
4
|
-
PostOrderBy,
|
|
5
|
-
PostDistinctExp,
|
|
6
|
-
PostFields,
|
|
7
|
-
PublishableStatus,
|
|
8
|
-
PostAssciations,
|
|
9
|
-
PostQueryOptions,
|
|
10
|
-
MediaQueryOptions,
|
|
11
|
-
UserQueryOptions,
|
|
12
|
-
UserFields,
|
|
13
|
-
ProductOrderBy,
|
|
14
|
-
ImageSize,
|
|
15
|
-
PostCategoryFields,
|
|
16
|
-
MediaFields,
|
|
17
|
-
PostCategory,
|
|
18
|
-
PostCategoryBoolExp,
|
|
19
|
-
PostCategoryOrderBy,
|
|
20
|
-
PostCategoryDistinctExp,
|
|
21
|
-
PostCategoryQueryOptions,
|
|
22
|
-
TagFields,
|
|
23
|
-
} from "@rxdrag/rxcms-models";
|
|
24
|
-
import { queryEntityList } from "./queryEntityList";
|
|
25
|
-
import { ListResult } from "@rxdrag/entify-lib";
|
|
26
|
-
import { EnvVariables } from "../types";
|
|
27
|
-
import { TPost } from "../view-model";
|
|
28
|
-
import { queryOneEntity } from "./queryOneEntity";
|
|
29
|
-
import { CategoryNode, collectCategoryIds } from "./collectCategoryIds";
|
|
30
|
-
|
|
31
|
-
export interface ListConditions {
|
|
32
|
-
category?: string; //category slug
|
|
33
|
-
page?: number;
|
|
34
|
-
pageSize: number;
|
|
35
|
-
orderBy?: ProductOrderBy[];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export async function queryPosts(
|
|
39
|
-
conditions: ListConditions,
|
|
40
|
-
coverSize: ImageSize | undefined,
|
|
41
|
-
envVariables: EnvVariables,
|
|
42
|
-
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
PostCategoryFields.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
PostFields.
|
|
93
|
-
PostFields.
|
|
94
|
-
PostFields.
|
|
95
|
-
PostFields.
|
|
96
|
-
PostFields.
|
|
97
|
-
PostFields.
|
|
98
|
-
PostFields.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
1
|
+
import {
|
|
2
|
+
Post,
|
|
3
|
+
PostBoolExp,
|
|
4
|
+
PostOrderBy,
|
|
5
|
+
PostDistinctExp,
|
|
6
|
+
PostFields,
|
|
7
|
+
PublishableStatus,
|
|
8
|
+
PostAssciations,
|
|
9
|
+
PostQueryOptions,
|
|
10
|
+
MediaQueryOptions,
|
|
11
|
+
UserQueryOptions,
|
|
12
|
+
UserFields,
|
|
13
|
+
ProductOrderBy,
|
|
14
|
+
ImageSize,
|
|
15
|
+
PostCategoryFields,
|
|
16
|
+
MediaFields,
|
|
17
|
+
PostCategory,
|
|
18
|
+
PostCategoryBoolExp,
|
|
19
|
+
PostCategoryOrderBy,
|
|
20
|
+
PostCategoryDistinctExp,
|
|
21
|
+
PostCategoryQueryOptions,
|
|
22
|
+
TagFields,
|
|
23
|
+
} from "@rxdrag/rxcms-models";
|
|
24
|
+
import { queryEntityList } from "./queryEntityList";
|
|
25
|
+
import { ListResult } from "@rxdrag/entify-lib";
|
|
26
|
+
import { EnvVariables } from "../types";
|
|
27
|
+
import { TPost } from "../view-model";
|
|
28
|
+
import { queryOneEntity } from "./queryOneEntity";
|
|
29
|
+
import { CategoryNode, collectCategoryIds } from "./collectCategoryIds";
|
|
30
|
+
|
|
31
|
+
export interface ListConditions {
|
|
32
|
+
category?: string; //category slug
|
|
33
|
+
page?: number;
|
|
34
|
+
pageSize: number;
|
|
35
|
+
orderBy?: ProductOrderBy[];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function queryPosts(
|
|
39
|
+
conditions: ListConditions,
|
|
40
|
+
coverSize: ImageSize | undefined,
|
|
41
|
+
envVariables: EnvVariables,
|
|
42
|
+
langAbbr: string,
|
|
43
|
+
addonFields?: (keyof Post)[]
|
|
44
|
+
) {
|
|
45
|
+
const { category: categorySlug, page = 1, pageSize } = conditions;
|
|
46
|
+
|
|
47
|
+
let where = {};
|
|
48
|
+
if (categorySlug) {
|
|
49
|
+
// 查询分类及其子分类
|
|
50
|
+
const category = await queryOneEntity<
|
|
51
|
+
PostCategory,
|
|
52
|
+
PostCategoryBoolExp,
|
|
53
|
+
PostCategoryOrderBy,
|
|
54
|
+
PostCategoryDistinctExp
|
|
55
|
+
>(
|
|
56
|
+
new PostCategoryQueryOptions(
|
|
57
|
+
[PostCategoryFields.id, PostCategoryFields.slug],
|
|
58
|
+
{
|
|
59
|
+
where: {
|
|
60
|
+
slug: {
|
|
61
|
+
_eq: categorySlug,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
// 支持三级结构
|
|
67
|
+
.children(
|
|
68
|
+
new PostCategoryQueryOptions([
|
|
69
|
+
PostCategoryFields.id,
|
|
70
|
+
PostCategoryFields.slug,
|
|
71
|
+
]).children([PostCategoryFields.id])
|
|
72
|
+
),
|
|
73
|
+
envVariables
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
if (category) {
|
|
77
|
+
const categoryIds = collectCategoryIds(
|
|
78
|
+
category as unknown as CategoryNode
|
|
79
|
+
);
|
|
80
|
+
where = {
|
|
81
|
+
[PostAssciations.category]: {
|
|
82
|
+
id: {
|
|
83
|
+
_in: categoryIds,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// 默认查询字段
|
|
91
|
+
const defaultFields = [
|
|
92
|
+
PostFields.id,
|
|
93
|
+
PostFields.title,
|
|
94
|
+
PostFields.slug,
|
|
95
|
+
PostFields.description,
|
|
96
|
+
PostFields.status,
|
|
97
|
+
PostFields.updatedAt,
|
|
98
|
+
PostFields.createdAt,
|
|
99
|
+
PostFields.publishedAt,
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
// 使用指定的字段或默认字段
|
|
103
|
+
const fields = addonFields || defaultFields;
|
|
104
|
+
|
|
105
|
+
const queryOptions = new PostQueryOptions(fields, {
|
|
106
|
+
offset: (page - 1) * pageSize,
|
|
107
|
+
limit: pageSize,
|
|
108
|
+
where: {
|
|
109
|
+
[PostFields.status]: {
|
|
110
|
+
_eq: PublishableStatus.published,
|
|
111
|
+
},
|
|
112
|
+
lang: {
|
|
113
|
+
abbr: {
|
|
114
|
+
_eq: langAbbr,
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
_or: [
|
|
118
|
+
{
|
|
119
|
+
[PostFields.isDeleted]: {
|
|
120
|
+
_eq: false,
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
[PostFields.isDeleted]: {
|
|
125
|
+
_isNull: true,
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
...where,
|
|
130
|
+
},
|
|
131
|
+
orderBy: [
|
|
132
|
+
{
|
|
133
|
+
[PostFields.pinToTop]: "desc",
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
[PostFields.seqValue]: "asc",
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
[PostFields.updatedAt]: "desc",
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
}).category([PostCategoryFields.id, PostCategoryFields.name, PostCategoryFields.slug])
|
|
143
|
+
.tags([TagFields.id, TagFields.name, TagFields.color]);
|
|
144
|
+
|
|
145
|
+
// 只有在需要查询封面图时才添加封面图查询
|
|
146
|
+
if (!addonFields || addonFields.includes("cover" as keyof Post)) {
|
|
147
|
+
queryOptions.cover(
|
|
148
|
+
new MediaQueryOptions().file([
|
|
149
|
+
"thumbnail",
|
|
150
|
+
coverSize
|
|
151
|
+
? `resize(width:${coverSize.width}, height:${coverSize.height})`
|
|
152
|
+
: "resize(width:480, height:180)",
|
|
153
|
+
])
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// 只有在需要查询作者时才添加作者查询
|
|
158
|
+
if (!addonFields || addonFields.includes("author" as keyof Post)) {
|
|
159
|
+
queryOptions.author(
|
|
160
|
+
new UserQueryOptions([UserFields.id, UserFields.name]).avatar(
|
|
161
|
+
new MediaQueryOptions([MediaFields.id, MediaFields.mediaType, MediaFields.mediaRef])
|
|
162
|
+
.file(["thumbnail", "original"])
|
|
163
|
+
)
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const result = await queryEntityList<
|
|
168
|
+
Post,
|
|
169
|
+
PostBoolExp,
|
|
170
|
+
PostOrderBy,
|
|
171
|
+
PostDistinctExp
|
|
172
|
+
>(queryOptions, envVariables);
|
|
173
|
+
|
|
174
|
+
return result as ListResult<TPost> | undefined;
|
|
175
|
+
}
|