@rxdrag/website-lib-core 0.0.11 → 0.0.13

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.
Files changed (36) hide show
  1. package/package.json +4 -4
  2. package/src/component-logic/modal.ts +11 -2
  3. package/src/controller/OpenableController.ts +5 -0
  4. package/src/controller/PageLoader.ts +1 -1
  5. package/src/entify/Entify.ts +56 -0
  6. package/src/entify/IEntify.ts +43 -3
  7. package/src/entify/lib/langFields.ts +2 -0
  8. package/src/entify/lib/newPageMetaOptions.ts +4 -6
  9. package/src/entify/lib/newQueryPageOptions.ts +14 -0
  10. package/src/entify/lib/queryAllProducts.ts +5 -0
  11. package/src/entify/lib/queryFeaturedProducts.ts +5 -0
  12. package/src/entify/lib/queryLangs.ts +8 -21
  13. package/src/entify/lib/queryLatestPosts.ts +6 -1
  14. package/src/entify/lib/queryOnePostBySlug.ts +27 -10
  15. package/src/entify/lib/queryOnePostCategoryBySlug.ts +5 -0
  16. package/src/entify/lib/queryOneProductBySlug.ts +13 -3
  17. package/src/entify/lib/queryOneProductCategoryBySlug.ts +24 -5
  18. package/src/entify/lib/queryOneTheme.ts +2 -1
  19. package/src/entify/lib/queryPageBySlug.ts +43 -0
  20. package/src/entify/lib/queryPageByType.ts +44 -0
  21. package/src/entify/lib/queryPostCategories.ts +7 -0
  22. package/src/entify/lib/queryPostSlugs.ts +5 -0
  23. package/src/entify/lib/queryPosts.ts +56 -39
  24. package/src/entify/lib/queryProductCategories.ts +7 -0
  25. package/src/entify/lib/queryProducts.ts +5 -0
  26. package/src/entify/lib/queryProductsInMenu.ts +14 -12
  27. package/src/entify/lib/queryUserPosts.ts +5 -0
  28. package/src/entify/lib/queryWebSiteSettings.ts +2 -3
  29. package/src/entify/lib/queryWebsite.ts +43 -0
  30. package/src/entify/lib/searchProducts.ts +7 -0
  31. package/src/entify/view-model/models.ts +0 -8
  32. package/src/react/components/ContactForm/index.tsx +6 -29
  33. package/src/react/components/Medias/index.tsx +270 -273
  34. package/src/react/components/ProductCard/ProductCta/index.tsx +1 -1
  35. package/src/react/components/RichTextOutline/index.tsx +4 -5
  36. package/src/react/components/RichTextOutline/useAcitviedHeading.ts +81 -54
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rxdrag/website-lib-core",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.ts"
@@ -24,9 +24,9 @@
24
24
  "@types/react-dom": "^18.2.7",
25
25
  "eslint": "^7.32.0",
26
26
  "typescript": "^5",
27
- "@rxdrag/entify-hooks": "0.2.42",
27
+ "@rxdrag/entify-hooks": "0.2.43",
28
+ "@rxdrag/slate-preview": "1.2.56",
28
29
  "@rxdrag/eslint-config-custom": "0.2.12",
29
- "@rxdrag/slate-preview": "1.2.55",
30
30
  "@rxdrag/tsconfig": "0.2.0"
31
31
  },
32
32
  "dependencies": {
@@ -35,7 +35,7 @@
35
35
  "lodash-es": "^4.17.21",
36
36
  "react": "^18.2.0",
37
37
  "react-dom": "^18.2.0",
38
- "@rxdrag/rxcms-models": "0.3.48"
38
+ "@rxdrag/rxcms-models": "0.3.49"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "astro": "^4.0.0 || ^5.0.0"
@@ -1,4 +1,9 @@
1
- import { DATA_OPENABLE, DATA_OPENABLE_ROLE, OpenAble } from "../controller";
1
+ import {
2
+ DATA_OPENABLE,
3
+ DATA_OPENABLE_ROLE,
4
+ DATA_POPUP_CTA,
5
+ OpenAble,
6
+ } from "../controller";
2
7
  import { HTMLElementsWithChildren, IMotionProps } from "./motion";
3
8
 
4
9
  export type ModalTriggerProps = IMotionProps & {
@@ -28,9 +33,13 @@ export function getModalPanelDataAttrs(openableKey?: string) {
28
33
  };
29
34
  }
30
35
 
31
- export function getModalTriggerDataAttrs(openableKey?: string) {
36
+ export function getModalTriggerDataAttrs(
37
+ openableKey: string | undefined,
38
+ callToAction?: string
39
+ ) {
32
40
  return {
33
41
  [DATA_OPENABLE]: openableKey,
34
42
  [DATA_OPENABLE_ROLE]: OpenAble.ModalTrigger,
43
+ [DATA_POPUP_CTA]: callToAction,
35
44
  };
36
45
  }
@@ -9,6 +9,7 @@ import {
9
9
  OpenAble,
10
10
  EVENT_SELECT,
11
11
  EVENT_UNSELECT,
12
+ DATA_POPUP_CTA,
12
13
  } from "./consts";
13
14
  import { applyInitialState } from "./applyInitialState";
14
15
 
@@ -130,6 +131,7 @@ export class OpenableController {
130
131
  constructor(protected doc: Document | undefined) {}
131
132
  protected unmountHandlers: (() => void)[] = [];
132
133
  protected eventBus = new EventBus();
134
+ public lastCta?: string | null;
133
135
 
134
136
  mount() {
135
137
  this.unmount();
@@ -152,6 +154,9 @@ export class OpenableController {
152
154
  // 查找 Modal 容器
153
155
  const modalContainer = this.getOpenableContainer(openableKey);
154
156
  if (modalContainer) {
157
+ if (target.getAttribute(DATA_POPUP_CTA)) {
158
+ this.lastCta = target.getAttribute(DATA_POPUP_CTA);
159
+ }
155
160
  modalContainer.classList.add("open");
156
161
  this.eventBus.emit(EVENT_OPEN, { key: openableKey, target });
157
162
  } else {
@@ -94,7 +94,7 @@ export class PageLoader implements IPageLoader {
94
94
  if (typeof window !== "undefined") {
95
95
  // 在客户端环境中
96
96
  this.doc.addEventListener("astro:page-load", handleEvent, {
97
- once: true,
97
+ //once: true,
98
98
  });
99
99
  // 只监听页面转场事件
100
100
  this.doc.addEventListener("astro:after-swap", handleEvent);
@@ -23,6 +23,10 @@ import { queryAllProducts } from "./lib/queryAllProducts";
23
23
  import { queryPostSlugs } from "./lib/queryPostSlugs";
24
24
  import { queryUserIds } from "./lib/queryUserIds";
25
25
  import { IEntify, PostPatinateOptions, PostsOptions } from "./IEntify";
26
+ import { queryWebsite } from "./lib/queryWebsite";
27
+ import { Page, PageType } from "@rxdrag/rxcms-models";
28
+ import { queryPageBySlug } from "./lib/queryPageBySlug";
29
+ import { queryPageByType } from "./lib/queryPageByType";
26
30
 
27
31
  export class Entify implements IEntify {
28
32
  private static instance: Entify | null = null;
@@ -48,6 +52,14 @@ export class Entify implements IEntify {
48
52
  );
49
53
  }
50
54
 
55
+ public getLang() {
56
+ return this.envVariables.language || "en-US";
57
+ }
58
+
59
+ public async getWebsite() {
60
+ return queryWebsite(this.envVariables);
61
+ }
62
+
51
63
  public async getTheme() {
52
64
  return await queryOneTheme(this.envVariables);
53
65
  }
@@ -64,6 +76,50 @@ export class Entify implements IEntify {
64
76
  return await queryLatestPosts(count, this.envVariables);
65
77
  }
66
78
 
79
+ public async getHomePage(): Promise<Page | undefined> {
80
+ return await this.getPageByType(PageType.Home);
81
+ }
82
+ public async getPostPage(): Promise<Page | undefined> {
83
+ return await this.getPageByType(PageType.Post);
84
+ }
85
+ public async getPostListPage(): Promise<Page | undefined> {
86
+ return await this.getPageByType(PageType.PostList);
87
+ }
88
+ public async getPostCategoryPage(): Promise<Page | undefined> {
89
+ return await this.getPageByType(PageType.PostCategory);
90
+ }
91
+ public async getProductPage(): Promise<Page | undefined> {
92
+ return await this.getPageByType(PageType.Product);
93
+ }
94
+ public async getProductListPage(): Promise<Page | undefined> {
95
+ return await this.getPageByType(PageType.ProductList);
96
+ }
97
+ public async getProductCategoryPage(): Promise<Page | undefined> {
98
+ return await this.getPageByType(PageType.ProductCategory);
99
+ }
100
+ public async getSearchPage(): Promise<Page | undefined> {
101
+ return await this.getPageByType(PageType.SearchList);
102
+ }
103
+ public async getProfilePage(): Promise<Page | undefined> {
104
+ return await this.getPageByType(PageType.Profile);
105
+ }
106
+ public async getThanksPage(): Promise<Page | undefined> {
107
+ return await this.getPageByType(PageType.Thanks);
108
+ }
109
+ public async get404Page(): Promise<Page | undefined> {
110
+ return await this.getPageByType(PageType.Page404);
111
+ }
112
+ public async getErrorPage(): Promise<Page | undefined> {
113
+ return await this.getPageByType(PageType.PageError);
114
+ }
115
+ public async getPageBySlug(slug: string): Promise<Page | undefined> {
116
+ return await queryPageBySlug(slug, this.envVariables);
117
+ }
118
+
119
+ public async getPageByType(pageType: PageType): Promise<Page | undefined> {
120
+ return await queryPageByType(pageType, this.envVariables);
121
+ }
122
+
67
123
  public async getPosts(options: PostsOptions) {
68
124
  const { category, coverSize, page, pageSize } = options;
69
125
  const conditions: ListConditions = { category, page, pageSize };
@@ -1,8 +1,14 @@
1
1
  import { IQueryOptions, ListResult } from "@rxdrag/entify-hooks";
2
2
  import { TSize } from "./types";
3
3
  import { ListConditions } from "./lib";
4
- import { TPost, TPostCategory, TProduct, TProductCategory, TUser } from "./view-model";
5
- import { Lang, Theme } from "@rxdrag/rxcms-models";
4
+ import {
5
+ TPost,
6
+ TPostCategory,
7
+ TProduct,
8
+ TProductCategory,
9
+ TUser,
10
+ } from "./view-model";
11
+ import { Lang, Page, PageType, Theme, Website } from "@rxdrag/rxcms-models";
6
12
 
7
13
  export type PostsOptions = {
8
14
  category?: string;
@@ -17,6 +23,7 @@ export type PostPatinateOptions = {
17
23
  };
18
24
 
19
25
  export interface IEntify {
26
+ getLang(): string;
20
27
  queryEntityList<
21
28
  T,
22
29
  WhereExp = unknown,
@@ -28,6 +35,8 @@ export interface IEntify {
28
35
  staticKey?: string
29
36
  ): Promise<ListResult<unknown> | undefined>;
30
37
 
38
+ getWebsite(): Promise<Website | undefined>;
39
+
31
40
  getTheme(): Promise<Theme | undefined>;
32
41
 
33
42
  getLangs(): Promise<Lang[] | undefined>;
@@ -38,11 +47,42 @@ export interface IEntify {
38
47
 
39
48
  getPosts(options: PostsOptions): Promise<TPost[] | undefined>;
40
49
 
50
+ getHomePage(): Promise<Page | undefined>;
51
+
52
+ getPostPage(): Promise<Page | undefined>;
53
+
54
+ getPostListPage(): Promise<Page | undefined>;
55
+
56
+ getPostCategoryPage(): Promise<Page | undefined>;
57
+
58
+ getProductPage(): Promise<Page | undefined>;
59
+
60
+ getProductListPage(): Promise<Page | undefined>;
61
+
62
+ getProductCategoryPage(): Promise<Page | undefined>;
63
+
64
+ getSearchPage(): Promise<Page | undefined>;
65
+
66
+ getProfilePage(): Promise<Page | undefined>;
67
+
68
+ getThanksPage(): Promise<Page | undefined>;
69
+
70
+ get404Page(): Promise<Page | undefined>;
71
+
72
+ getErrorPage(): Promise<Page | undefined>;
73
+
74
+ getPageBySlug(slug: string): Promise<Page | undefined>;
75
+
76
+ getPageByType(pageType: PageType): Promise<Page | undefined>;
77
+
41
78
  getPostListPaths(options: PostPatinateOptions): Promise<unknown>;
42
79
 
43
80
  getPostPaths(): Promise<unknown>;
44
81
 
45
- getPostBySlug(slug: string, coverSize: TSize | undefined): Promise<TPost | undefined>;
82
+ getPostBySlug(
83
+ slug: string,
84
+ coverSize: TSize | undefined
85
+ ): Promise<TPost | undefined>;
46
86
 
47
87
  getPostSlugs(): Promise<Array<string | undefined>>;
48
88
 
@@ -9,4 +9,6 @@ export const langFields = [
9
9
  LangFields.localName,
10
10
  LangFields.icon,
11
11
  LangFields.htmlLang,
12
+ //TODO 用枚举有时会出空值
13
+ "urlFragment" as LangFields.urlFragment,
12
14
  ];
@@ -1,8 +1,8 @@
1
- import { PageMetaQueryOptions, PageMetaFields, MediaQueryOptions, MediaFields } from "@rxdrag/rxcms-models";
1
+ import { PageMetaQueryOptions, PageMetaFields } from "@rxdrag/rxcms-models";
2
2
  import { newOgImageQueryOptions } from "./newOgImageQueryOptions";
3
3
 
4
4
  export function newPageMetaOptions() {
5
- return new PageMetaQueryOptions([
5
+ return new PageMetaQueryOptions([
6
6
  PageMetaFields.id,
7
7
  PageMetaFields.seoTitle,
8
8
  PageMetaFields.seoKeywords,
@@ -14,7 +14,5 @@ export function newPageMetaOptions() {
14
14
  PageMetaFields.ogSiteName,
15
15
  PageMetaFields.xCard,
16
16
  PageMetaFields.xSite,
17
- ]).ogImage(
18
- newOgImageQueryOptions()
19
- )
20
- }
17
+ ]).ogImage(newOgImageQueryOptions());
18
+ }
@@ -0,0 +1,14 @@
1
+ import {
2
+ PageQueryOptions,
3
+ PageFields,
4
+ } from "@rxdrag/rxcms-models";
5
+ import { newPageMetaOptions } from "./newPageMetaOptions";
6
+
7
+ //查询一个产品的参数,不带条件
8
+ export function newQueryPageOptions() {
9
+ return new PageQueryOptions([
10
+ PageFields.id,
11
+ PageFields.slug,
12
+ PageFields.title,
13
+ ]).meta(newPageMetaOptions());
14
+ }
@@ -20,6 +20,11 @@ export async function queryAllProducts(envVariables: EnvVariables) {
20
20
  [ProductFields.status]: {
21
21
  _eq: PublishableStatus.published,
22
22
  },
23
+ lang: {
24
+ abbr: {
25
+ _eq: envVariables.language,
26
+ },
27
+ },
23
28
  },
24
29
  orderBy: [{ [ProductFields.seqValue]: "asc" }],
25
30
  }
@@ -37,6 +37,11 @@ export async function queryFeaturedProducts(
37
37
  featured: {
38
38
  _eq: true,
39
39
  },
40
+ lang: {
41
+ abbr: {
42
+ _eq: envVariables.language,
43
+ },
44
+ },
40
45
  },
41
46
  orderBy: [{ [ProductFields.seqValue]: "asc" }],
42
47
  }
@@ -4,12 +4,12 @@ import {
4
4
  LangDistinctExp,
5
5
  LangOrderBy,
6
6
  LangQueryOptions,
7
- LangFields,
8
7
  LangAssciations,
9
8
  } from "@rxdrag/rxcms-models";
10
9
  import { ListResult } from "@rxdrag/entify-hooks";
11
10
  import { EnvVariables } from "../types";
12
11
  import { createEntifyClient } from "./createEntifyClient";
12
+ import { langFields } from "./langFields";
13
13
 
14
14
  export async function queryLangs(envVariables: EnvVariables) {
15
15
  const client = createEntifyClient(envVariables);
@@ -20,28 +20,15 @@ export async function queryLangs(envVariables: EnvVariables) {
20
20
  LangOrderBy,
21
21
  LangDistinctExp
22
22
  >(
23
- new LangQueryOptions(
24
- [
25
- LangFields.id,
26
- LangFields.abbr,
27
- LangFields.circleIcon,
28
- LangFields.cnName,
29
- LangFields.enName,
30
- LangFields.localName,
31
- LangFields.icon,
32
- LangFields.htmlLang,
33
- ],
34
- {
35
- where: {
36
- [LangAssciations.websites]: {
37
- id: {
38
- _eq: envVariables.websiteId,
39
- },
23
+ new LangQueryOptions(langFields, {
24
+ where: {
25
+ [LangAssciations.websites]: {
26
+ id: {
27
+ _eq: envVariables.websiteId,
40
28
  },
41
29
  },
42
- }
43
- ).setNoQuery(!envVariables.websiteId)
30
+ },
31
+ }).setNoQuery(!envVariables.websiteId)
44
32
  );
45
-
46
33
  return result as ListResult<Lang> | undefined;
47
34
  }
@@ -1,4 +1,4 @@
1
- import { ListResult, OrderBy } from "@rxdrag/entify-hooks";
1
+ import { ListResult } from "@rxdrag/entify-hooks";
2
2
  import {
3
3
  PostBoolExp,
4
4
  PostOrderBy,
@@ -45,6 +45,11 @@ export async function queryLatestPosts(
45
45
  [PostFields.status]: {
46
46
  _eq: PublishableStatus.published,
47
47
  },
48
+ lang: {
49
+ abbr: {
50
+ _eq: envVariables.language,
51
+ },
52
+ },
48
53
  },
49
54
  }
50
55
  )
@@ -1,20 +1,37 @@
1
- import { Post, PostBoolExp, PostOrderBy, PostDistinctExp } from "@rxdrag/rxcms-models";
1
+ import {
2
+ Post,
3
+ PostBoolExp,
4
+ PostOrderBy,
5
+ PostDistinctExp,
6
+ } from "@rxdrag/rxcms-models";
2
7
  import { newQueryOnePostOptions } from "./newQueryPostOptions";
3
8
  import { queryOneEntity } from "./queryOneEntity";
4
9
  import { EnvVariables, TSize } from "../types";
5
10
  import { TPost } from "../view-model";
6
11
 
7
- export async function queryOnePostBySlug(slug: string, coverSize: TSize | undefined, envVariables: EnvVariables) {
8
-
9
- const post = await queryOneEntity<Post, PostBoolExp, PostOrderBy, PostDistinctExp>(
10
- newQueryOnePostOptions(coverSize)
11
- .setQueryArgs({
12
- where: {
13
- slug: {
14
- "_eq": slug
12
+ export async function queryOnePostBySlug(
13
+ slug: string,
14
+ coverSize: TSize | undefined,
15
+ envVariables: EnvVariables
16
+ ) {
17
+ const post = await queryOneEntity<
18
+ Post,
19
+ PostBoolExp,
20
+ PostOrderBy,
21
+ PostDistinctExp
22
+ >(
23
+ newQueryOnePostOptions(coverSize).setQueryArgs({
24
+ where: {
25
+ slug: {
26
+ _eq: slug,
27
+ },
28
+ lang: {
29
+ abbr: {
30
+ _eq: envVariables.language,
15
31
  },
16
32
  },
17
- }),
33
+ },
34
+ }),
18
35
  envVariables
19
36
  );
20
37
  return post as TPost | undefined;
@@ -20,6 +20,11 @@ export async function queryOnePostCategoryBySlug(slug: string, envVariables: Env
20
20
  slug: {
21
21
  "_eq": slug
22
22
  },
23
+ lang: {
24
+ abbr: {
25
+ _eq: envVariables.language,
26
+ },
27
+ },
23
28
  },
24
29
  }
25
30
  ),
@@ -26,6 +26,11 @@ export async function queryOneProductBySlug(
26
26
  slug: {
27
27
  _eq: slug,
28
28
  },
29
+ lang: {
30
+ abbr: {
31
+ _eq: envVariables.language,
32
+ },
33
+ },
29
34
  },
30
35
  }),
31
36
  envVariables
@@ -54,9 +59,14 @@ export async function queryOneProductBySlug(
54
59
  envVariables
55
60
  );
56
61
 
57
- tProduct.related = result?.items?.map((pro) => productToViewModel(pro)) as
58
- | TProduct[]
59
- | undefined;
62
+ const relatedProducts = result?.items?.map((pro) =>
63
+ productToViewModel(pro)
64
+ ) as TProduct[] | undefined;
65
+
66
+ //重新排序后赋值
67
+ tProduct.related = product?.relatedSlugs.map((slug) =>
68
+ relatedProducts?.find((p) => p.slug === slug)
69
+ ) as TProduct[] | undefined;
60
70
  }
61
71
 
62
72
  return tProduct;
@@ -1,11 +1,25 @@
1
- import { ProductCategory, ProductCategoryBoolExp, ProductCategoryOrderBy, ProductCategoryDistinctExp, ProductCategoryQueryOptions, ProductCategoryFields } from "@rxdrag/rxcms-models";
1
+ import {
2
+ ProductCategory,
3
+ ProductCategoryBoolExp,
4
+ ProductCategoryOrderBy,
5
+ ProductCategoryDistinctExp,
6
+ ProductCategoryQueryOptions,
7
+ ProductCategoryFields,
8
+ } from "@rxdrag/rxcms-models";
2
9
  import { queryOneEntity } from "./queryOneEntity";
3
10
  import { EnvVariables } from "../types";
4
11
  import { TProductCategory } from "../view-model";
5
12
 
6
- export async function queryOneProductCategoryBySlug(slug: string, envVariables: EnvVariables) {
7
-
8
- const productCategory = await queryOneEntity<ProductCategory, ProductCategoryBoolExp, ProductCategoryOrderBy, ProductCategoryDistinctExp>(
13
+ export async function queryOneProductCategoryBySlug(
14
+ slug: string,
15
+ envVariables: EnvVariables
16
+ ) {
17
+ const productCategory = await queryOneEntity<
18
+ ProductCategory,
19
+ ProductCategoryBoolExp,
20
+ ProductCategoryOrderBy,
21
+ ProductCategoryDistinctExp
22
+ >(
9
23
  new ProductCategoryQueryOptions(
10
24
  [
11
25
  ProductCategoryFields.id,
@@ -18,7 +32,12 @@ export async function queryOneProductCategoryBySlug(slug: string, envVariables:
18
32
  {
19
33
  where: {
20
34
  slug: {
21
- "_eq": slug
35
+ _eq: slug,
36
+ },
37
+ lang: {
38
+ abbr: {
39
+ _eq: envVariables.language,
40
+ },
22
41
  },
23
42
  },
24
43
  }
@@ -60,7 +60,8 @@ export async function queryOneTheme(envVariables: EnvVariables) {
60
60
  ThemeConfigFields.mobile,
61
61
  ThemeConfigFields.tel,
62
62
  ThemeConfigFields.wechat,
63
- //ThemeConfigFields.websiteName,
63
+ ThemeConfigFields.domain,
64
+ //ThemeConfigFields.websiteName,
64
65
  ]).contactAvatar(new MediaQueryOptions().file(["thumbnail"]))
65
66
  )
66
67
  .lang(langFields)
@@ -0,0 +1,43 @@
1
+ import {
2
+ Page,
3
+ PageBoolExp,
4
+ PageOrderBy,
5
+ PageDistinctExp,
6
+ } from "@rxdrag/rxcms-models";
7
+ import { queryOneEntity } from "./queryOneEntity";
8
+ import { EnvVariables } from "../types";
9
+ import { newQueryPageOptions } from "./newQueryPageOptions";
10
+
11
+ export async function queryPageBySlug(
12
+ slug: string,
13
+ envVariables: EnvVariables
14
+ ) {
15
+ const post = await queryOneEntity<
16
+ Page,
17
+ PageBoolExp,
18
+ PageOrderBy,
19
+ PageDistinctExp
20
+ >(
21
+ newQueryPageOptions().setQueryArgs({
22
+ where: {
23
+ slug: {
24
+ _eq: slug,
25
+ },
26
+ theme: {
27
+ lang: {
28
+ abbr: {
29
+ _eq: envVariables.language,
30
+ },
31
+ },
32
+ website: {
33
+ id: {
34
+ _eq: envVariables.websiteId,
35
+ },
36
+ },
37
+ },
38
+ },
39
+ }),
40
+ { ...envVariables, websiteId: undefined }
41
+ );
42
+ return post as Page | undefined;
43
+ }
@@ -0,0 +1,44 @@
1
+ import {
2
+ Page,
3
+ PageBoolExp,
4
+ PageOrderBy,
5
+ PageDistinctExp,
6
+ PageType,
7
+ } from "@rxdrag/rxcms-models";
8
+ import { queryOneEntity } from "./queryOneEntity";
9
+ import { EnvVariables } from "../types";
10
+ import { newQueryPageOptions } from "./newQueryPageOptions";
11
+
12
+ export async function queryPageByType(
13
+ pageType: PageType,
14
+ envVariables: EnvVariables
15
+ ) {
16
+ const post = await queryOneEntity<
17
+ Page,
18
+ PageBoolExp,
19
+ PageOrderBy,
20
+ PageDistinctExp
21
+ >(
22
+ newQueryPageOptions().setQueryArgs({
23
+ where: {
24
+ pageType: {
25
+ _eq: pageType,
26
+ },
27
+ theme: {
28
+ lang: {
29
+ abbr: {
30
+ _eq: envVariables.language,
31
+ },
32
+ },
33
+ website: {
34
+ id: {
35
+ _eq: envVariables.websiteId,
36
+ },
37
+ },
38
+ },
39
+ },
40
+ }),
41
+ { ...envVariables, websiteId: undefined }
42
+ );
43
+ return post as Page | undefined;
44
+ }
@@ -30,6 +30,13 @@ export async function queryPostCategories(envVariables: EnvVariables) {
30
30
  PostCategoryFields.description,
31
31
  ],
32
32
  {
33
+ where: {
34
+ lang: {
35
+ abbr: {
36
+ _eq: envVariables.language,
37
+ },
38
+ },
39
+ },
33
40
  orderBy: [{ [PostCategoryFields.seqValue]: "asc" }],
34
41
  }
35
42
  ).posts(
@@ -18,6 +18,11 @@ export async function queryPostSlugs(envVariables: EnvVariables) {
18
18
  [PostFields.status]: {
19
19
  _eq: PublishableStatus.published,
20
20
  },
21
+ lang: {
22
+ abbr: {
23
+ _eq: envVariables.language,
24
+ },
25
+ },
21
26
  },
22
27
  orderBy: [{ [PostFields.seqValue]: "asc" }],
23
28
  });