@c-rex/templates 0.1.13 → 0.1.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c-rex/templates",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src"
@@ -56,7 +56,8 @@
56
56
  "react": "^18.3.1",
57
57
  "react-dom": "^18.3.1",
58
58
  "react-i18next": "^15.5.1",
59
- "sonner": "^2.0.5"
59
+ "sonner": "^2.0.5",
60
+ "zustand": "^5.0.8"
60
61
  },
61
62
  "peerDependencies": {
62
63
  "react": "^18.3.1",
@@ -40,7 +40,8 @@ export const DocumentsLayout = async ({ params }: Props) => {
40
40
  document,
41
41
  article,
42
42
  rootNode,
43
- availableVersions,
43
+ articleAvailableVersions,
44
+ documentAvailableVersions,
44
45
  attachments,
45
46
  articleInfo,
46
47
  documentInfo
@@ -54,7 +55,8 @@ export const DocumentsLayout = async ({ params }: Props) => {
54
55
  document={document}
55
56
  article={article}
56
57
  rootNode={rootNode}
57
- availableVersions={availableVersions}
58
+ articleAvailableVersions={articleAvailableVersions}
59
+ documentAvailableVersions={documentAvailableVersions}
58
60
  attachments={attachments!}
59
61
  articleInfo={articleInfo!}
60
62
  documentInfo={documentInfo!}
@@ -4,21 +4,22 @@ import React, { FC, useEffect, useState } from "react";
4
4
  import { ArticleWrapper } from "../wrapper";
5
5
  import { CollectionResult, TreeOfContent } from "@c-rex/interfaces";
6
6
  import { createAvailableVersionList, generateTreeOfContent } from "@c-rex/utils";
7
- import { DOCUMENTS_TYPE_AND_LINK } from "@c-rex/constants";
7
+ import { DOCUMENTS_TYPE_AND_LINK, TOPICS_TYPE_AND_LINK } from "@c-rex/constants";
8
8
  import { useAppConfig } from "@c-rex/contexts/config-provider";
9
+ import { HighlightProvider } from "@c-rex/contexts/highlight-provider";
9
10
 
10
11
  export const DocumentsPage: FC<Omit<CollectionResult, "metaTags">> = ({
11
12
  articleHtml,
12
13
  document,
13
14
  article,
14
15
  rootNode,
15
- availableVersions,
16
+ articleAvailableVersions,
17
+ documentAvailableVersions,
16
18
  attachments,
17
19
  articleInfo,
18
20
  documentInfo
19
21
  }) => {
20
22
  const { setPackageID } = useAppConfig();
21
- const availableVersionsSidebar = createAvailableVersionList(availableVersions, article.languages[0]!, DOCUMENTS_TYPE_AND_LINK);
22
23
  const breadcrumbItems = [{
23
24
  link: "/",
24
25
  label: rootNode?.informationUnits[0]?.labels[0]?.value as string,
@@ -47,17 +48,25 @@ export const DocumentsPage: FC<Omit<CollectionResult, "metaTags">> = ({
47
48
  }, []);
48
49
 
49
50
  return (
50
- <ArticleWrapper
51
- htmlContent={articleHtml}
52
- documentLang={document.languages[0]!}
53
- articleLang={article.languages[0]!}
54
- availableVersions={availableVersionsSidebar}
55
- loading={loading}
56
- documents={attachments!}
57
- articleInfo={articleInfo!}
58
- documentInfo={documentInfo!}
59
- breadcrumbItems={breadcrumbItems}
60
- treeOfContent={tree}
61
- />
51
+ <HighlightProvider>
52
+ <ArticleWrapper
53
+ htmlContent={articleHtml}
54
+ documentLang={document.languages[0]!}
55
+ articleLang={article.languages[0]!}
56
+ articleAvailableVersions={
57
+ createAvailableVersionList(articleAvailableVersions, article.languages[0]!, TOPICS_TYPE_AND_LINK)
58
+ }
59
+ documentAvailableVersions={
60
+ createAvailableVersionList(documentAvailableVersions, document.languages[0]!, DOCUMENTS_TYPE_AND_LINK)
61
+ }
62
+
63
+ loading={loading}
64
+ documents={attachments!}
65
+ articleInfo={articleInfo!}
66
+ documentInfo={documentInfo!}
67
+ breadcrumbItems={breadcrumbItems}
68
+ treeOfContent={tree}
69
+ />
70
+ </HighlightProvider>
62
71
  );
63
72
  };
@@ -38,7 +38,8 @@ export const TopicsLayout = async ({ params }: { params: { id: string } }) => {
38
38
  document,
39
39
  article,
40
40
  rootNode,
41
- availableVersions,
41
+ articleAvailableVersions,
42
+ documentAvailableVersions,
42
43
  attachments,
43
44
  articleInfo,
44
45
  documentInfo
@@ -52,7 +53,8 @@ export const TopicsLayout = async ({ params }: { params: { id: string } }) => {
52
53
  document={document}
53
54
  article={article}
54
55
  rootNode={rootNode}
55
- availableVersions={availableVersions}
56
+ articleAvailableVersions={articleAvailableVersions}
57
+ documentAvailableVersions={documentAvailableVersions}
56
58
  attachments={attachments!}
57
59
  articleInfo={articleInfo!}
58
60
  documentInfo={documentInfo!}
@@ -4,14 +4,16 @@ import React, { FC, useEffect, useState } from "react";
4
4
  import { ArticleWrapper } from "../wrapper";
5
5
  import { CollectionResult, TreeOfContent } from "@c-rex/interfaces";
6
6
  import { createAvailableVersionList, generateBreadcrumbItems, generateTreeOfContent } from "@c-rex/utils";
7
- import { TOPICS_TYPE_AND_LINK } from "@c-rex/constants";
7
+ import { DOCUMENTS_TYPE_AND_LINK, TOPICS_TYPE_AND_LINK } from "@c-rex/constants";
8
8
  import { useAppConfig } from "@c-rex/contexts/config-provider";
9
+ import { HighlightProvider } from "@c-rex/contexts/highlight-provider";
9
10
 
10
11
  export const TopicsPage: FC<Omit<CollectionResult, "metaTags">> = ({
11
12
  articleHtml,
12
13
  document,
13
14
  article,
14
- availableVersions,
15
+ articleAvailableVersions,
16
+ documentAvailableVersions,
15
17
  attachments,
16
18
  articleInfo,
17
19
  documentInfo
@@ -19,7 +21,6 @@ export const TopicsPage: FC<Omit<CollectionResult, "metaTags">> = ({
19
21
  const { setPackageID } = useAppConfig();
20
22
  const [loading, setLoading] = useState<boolean>(true);
21
23
  const [tree, setTreeOfContent] = useState<TreeOfContent[]>([]);
22
- const availableVersionsSidebar = createAvailableVersionList(availableVersions, article.languages[0]!, TOPICS_TYPE_AND_LINK);
23
24
  const [breadcrumbItems, setBreadcrumbItems] = useState<TreeOfContent[]>([]);
24
25
 
25
26
  useEffect(() => {
@@ -39,17 +40,24 @@ export const TopicsPage: FC<Omit<CollectionResult, "metaTags">> = ({
39
40
  }, []);
40
41
 
41
42
  return (
42
- <ArticleWrapper
43
- htmlContent={articleHtml}
44
- documentLang={document.languages[0]!}
45
- articleLang={article.languages[0]!}
46
- availableVersions={availableVersionsSidebar}
47
- loading={loading}
48
- documents={attachments!}
49
- articleInfo={articleInfo!}
50
- documentInfo={documentInfo!}
51
- breadcrumbItems={breadcrumbItems}
52
- treeOfContent={tree}
53
- />
43
+ <HighlightProvider>
44
+ <ArticleWrapper
45
+ htmlContent={articleHtml}
46
+ documentLang={document.languages[0]!}
47
+ articleLang={article.languages[0]!}
48
+ articleAvailableVersions={
49
+ createAvailableVersionList(articleAvailableVersions, article.languages[0]!, TOPICS_TYPE_AND_LINK)
50
+ }
51
+ documentAvailableVersions={
52
+ createAvailableVersionList(documentAvailableVersions, document.languages[0]!, DOCUMENTS_TYPE_AND_LINK)
53
+ }
54
+ loading={loading}
55
+ documents={attachments!}
56
+ articleInfo={articleInfo!}
57
+ documentInfo={documentInfo!}
58
+ breadcrumbItems={breadcrumbItems}
59
+ treeOfContent={tree}
60
+ />
61
+ </HighlightProvider>
54
62
  );
55
63
  };
@@ -1,6 +1,6 @@
1
1
  "use client"
2
2
 
3
- import React from "react";
3
+ import React, { useEffect, useRef, useState } from "react";
4
4
  import { SidebarTrigger } from "@c-rex/ui/sidebar";
5
5
  import { LeftSidebar } from "@c-rex/components/left-sidebar";
6
6
  import { RightSidebar } from "@c-rex/components/right-sidebar";
@@ -9,12 +9,23 @@ import { RenderArticle } from "@c-rex/components/render-article";
9
9
  import { articleInfoItemType, DocumentsType } from "@c-rex/types";
10
10
  import { AvailableVersionsInterface, TreeOfContent } from "@c-rex/interfaces";
11
11
  import { Separator } from "@c-rex/ui/separator";
12
+ import { ArrowBigLeft, PanelRight, ArrowBigRight, StarIcon, Search, X, Pen, PenOff } from "lucide-react";
12
13
  import { SearchInput } from "../../../components/src/navbar/search-input";
14
+ import { useMultiSidebar } from "@c-rex/ui/sidebar";
15
+ import { Button } from "@c-rex/ui/button";
16
+ import { useQueryState } from "nuqs";
17
+ import { cn } from "@c-rex/utils";
18
+ import { useHighlight } from "@c-rex/contexts/highlight-provider";
19
+ import { useHighlightStore } from "@c-rex/components/highlight-store";
20
+ import { useTranslations } from "next-intl";
21
+
13
22
 
14
23
  type Props = {
15
24
  documentLang: string,
16
25
  articleLang: string,
17
- availableVersions: AvailableVersionsInterface[],
26
+ articleAvailableVersions: AvailableVersionsInterface[],
27
+ documentAvailableVersions: AvailableVersionsInterface[],
28
+
18
29
  htmlContent: string,
19
30
 
20
31
  articleInfo: articleInfoItemType[],
@@ -31,53 +42,114 @@ export const ArticleWrapper = ({
31
42
  documents,
32
43
  documentLang,
33
44
  articleLang,
34
- availableVersions,
45
+ articleAvailableVersions,
46
+ documentAvailableVersions,
35
47
  loading,
36
48
  treeOfContent,
37
49
  documentInfo,
38
50
  articleInfo,
39
51
  breadcrumbItems,
40
52
  }: Props) => {
53
+ const t = useTranslations();
54
+ const inputRef = useRef<HTMLInputElement>(null);
55
+ const { next, prev } = useHighlight();
56
+ const [open, setOpen] = useState(false);
57
+ const enableHighlight = useHighlightStore((state) => state.enable);
58
+ const toggleHighlight = useHighlightStore((state) => state.toggleHighlight);
59
+ const { rightSidebar } = useMultiSidebar()
60
+ const [query, setQuery] = useQueryState("q");
61
+
62
+ useEffect(() => {
63
+ if (open && inputRef.current) {
64
+ inputRef.current.focus();
65
+ }
66
+ }, [open]);
67
+
41
68
  return (
42
- <div className="flex w-full overflow-hidden">
69
+ <div className="flex w-full">
43
70
  <LeftSidebar
44
71
  lang={documentLang}
45
72
  data={treeOfContent}
46
73
  loading={loading}
47
74
  side="left"
48
75
  />
49
- <div className="flex-1 overflow-auto">
50
- <div className=" p-4">
51
-
52
- <header className="flex h-12 gap-2 items-center justify-between">
53
- <div className="flex items-center gap-2">
54
- <SidebarTrigger side="left" />
55
- <Separator
56
- orientation="vertical"
57
- className="data-[orientation=vertical]:h-4 hidden sm:block"
58
- />
59
- <Breadcrumb items={breadcrumbItems} loading={loading} lang={documentLang} />
60
- </div>
61
- <SearchInput showInput={true} showPkgFilter={true} placedOn="BODY" />
62
- </header>
63
-
64
- <RenderArticle htmlContent={htmlContent} contentLang={articleLang} />
76
+ <div className="flex-1 p-4">
77
+ <header className="flex h-12 gap-2 items-center justify-between">
78
+ <div className="flex items-center gap-2">
79
+ <SidebarTrigger side="left" />
80
+ <Separator
81
+ orientation="vertical"
82
+ className="data-[orientation=vertical]:h-4 hidden sm:block"
83
+ />
84
+ <Breadcrumb items={breadcrumbItems} loading={loading} lang={documentLang} />
85
+ </div>
86
+ <SearchInput showInput={true} showPkgFilter={true} placedOn="BODY" />
87
+ </header>
65
88
 
66
- </div>
67
- <SidebarTrigger
68
- side="right"
69
- variant="default"
70
- size="default"
71
- className="fixed h-9 w-9 right-8 bottom-8 rounded-full drop-shadow-lg lg:hidden"
72
- />
89
+ <RenderArticle htmlContent={htmlContent} contentLang={articleLang} />
90
+
91
+ <div className="w-full sm:w-auto justify-between bg-primary text-primary-foreground rounded-full shadow-lg flex sticky bottom-4 p-2 float-right gap-2 transition-all duration-300">
92
+
93
+ <div className="flex items-center">
94
+ <input
95
+ type="text"
96
+ value={query as string || ""}
97
+ ref={inputRef}
98
+ onKeyDown={(e) => {
99
+ if (e.key === "Enter") {
100
+ next();
101
+ }
102
+ }}
103
+
104
+ onChange={(e) => setQuery(e.target.value || null)}
73
105
 
106
+ placeholder={t("search")}
107
+ className={cn(
108
+ "border border-gray-300 rounded left-12 transition-all duration-300 rounded-full h-9 bg-secondary text-secondary-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",
109
+ open ? "w-48 opacity-100 px-2 mr-2" : "w-0 opacity-0 px-0"
110
+ )}
111
+ />
112
+
113
+ <Button
114
+ variant="ghost" size="icon" rounded="full"
115
+ onClick={() => setOpen(!open)}
116
+ >
117
+ {open ? <X className="w-5 h-5" /> : <Search className="w-5 h-5" />}
118
+ </Button>
119
+
120
+ </div>
121
+
122
+ <Button variant="ghost" size="icon" rounded="full" onClick={prev}>
123
+ <ArrowBigLeft className="h-5 w-5" />
124
+ </Button>
125
+ <Button variant="ghost" size="icon" rounded="full" onClick={next}>
126
+ <ArrowBigRight className="h-5 w-5" />
127
+ </Button>
128
+
129
+ <Button variant="ghost" size="icon" rounded="full" onClick={rightSidebar.toggleSidebar}>
130
+ <StarIcon className="h-5 w-5" />
131
+ </Button>
132
+
133
+ <Button variant="ghost" size="icon" rounded="full" onClick={() => toggleHighlight(!enableHighlight)}>
134
+ {enableHighlight ?
135
+ <PenOff className="h-5 w-5" /> :
136
+ <Pen className="h-5 w-5" />
137
+ }
138
+ </Button>
139
+
140
+ <Button variant="ghost" size="icon" rounded="full" onClick={rightSidebar.toggleSidebar}>
141
+ <PanelRight className="h-5 w-5" />
142
+ </Button>
143
+
144
+ </div>
74
145
  </div>
75
146
  <RightSidebar
76
147
  side="right"
77
148
  articleInfo={articleInfo}
78
149
  documentInfo={documentInfo}
79
150
  files={documents}
80
- availableVersions={availableVersions}
151
+ articleAvailableVersions={articleAvailableVersions}
152
+ documentAvailableVersions={documentAvailableVersions}
81
153
  />
82
154
  </div>
83
155
  );
@@ -1,5 +1,5 @@
1
1
  import { DirectoryNodesService, InformationUnitsService } from "@c-rex/services";
2
- import { CollectionContext, CollectionResult, DirectoryNodes, informationUnitsItems } from "@c-rex/interfaces";
2
+ import { CollectionContext, CollectionResult, DirectoryNodes, informationUnitsItems, informationUnitsResponseItem } from "@c-rex/interfaces";
3
3
  import * as cheerio from "cheerio"
4
4
  import { articleInfoItemType, metaTags } from "@c-rex/types";
5
5
 
@@ -72,8 +72,13 @@ export abstract class BaseArticleCollector {
72
72
 
73
73
  if (this.collectVersions) {
74
74
  tasks.push({
75
- name: 'versions',
76
- task: () => this.getVersions(context)
75
+ name: 'articleVersions',
76
+ task: () => this.getArticleVersions(context)
77
+ });
78
+
79
+ tasks.push({
80
+ name: 'documentVersions',
81
+ task: () => this.getDocumentVersions(context)
77
82
  });
78
83
  }
79
84
 
@@ -120,13 +125,6 @@ export abstract class BaseArticleCollector {
120
125
  });
121
126
  }
122
127
 
123
- protected async getVersions(context: CollectionContext) {
124
- return await this.informationService.getList({
125
- restrict: [`versionOf.shortId=${context.informationUnitsItem.versionOf.shortId}`],
126
- fields: ["renditions", "class", "languages", "labels"],
127
- });
128
- }
129
-
130
128
  protected async getDocument(context: CollectionContext) {
131
129
  if (context.rootNode.informationUnits[0]) {
132
130
  const infoId = context.rootNode.informationUnits[0].shortId;
@@ -166,6 +164,14 @@ export abstract class BaseArticleCollector {
166
164
  throw new Error("getHtmlContent must be implemented by subclass");
167
165
  }
168
166
 
167
+ protected async getArticleVersions(context: CollectionContext): Promise<informationUnitsResponseItem[]> {
168
+ throw new Error("getArticleVersions must be implemented by subclass");
169
+ }
170
+
171
+ protected async getDocumentVersions(context: CollectionContext): Promise<informationUnitsResponseItem[]> {
172
+ throw new Error("getDocumentVersions must be implemented by subclass");
173
+ }
174
+
169
175
  protected splitHtmlContentAndTags(html: string): { metaTags: metaTags, articleHtml: string } {
170
176
  const $ = cheerio.load(html)
171
177
 
@@ -191,7 +197,8 @@ export abstract class BaseArticleCollector {
191
197
  document: data.document,
192
198
  article: context.informationUnitsItem,
193
199
  rootNode: context.rootNode,
194
- availableVersions: data.versions?.items || [],
200
+ articleAvailableVersions: data.articleVersions || [],
201
+ documentAvailableVersions: data.documentVersions || [],
195
202
  }
196
203
 
197
204
  if (this.collectArticleInfo) {
@@ -1,5 +1,5 @@
1
1
  import { BaseArticleCollector } from './BaseArticleCollector';
2
- import { CollectionContext } from "@c-rex/interfaces";
2
+ import { CollectionContext, informationUnitsResponseItem } from "@c-rex/interfaces";
3
3
  import { RenditionsService } from "@c-rex/services";
4
4
  import { DocumentsType } from '@c-rex/types';
5
5
  import { getFileRenditions } from '@c-rex/utils';
@@ -33,6 +33,35 @@ export class DocumentArticleCollector extends BaseArticleCollector {
33
33
  });
34
34
  }
35
35
 
36
+ protected async getDocumentVersions(context: CollectionContext): Promise<informationUnitsResponseItem[]> {
37
+ const versions = await this.informationService.getList({
38
+ restrict: [`versionOf.shortId=${context.informationUnitsItem.versionOf.shortId}`],
39
+ fields: ["renditions", "class", "languages", "labels"],
40
+ })
41
+
42
+ return versions.items;
43
+ }
44
+
45
+ protected async getArticleVersions(context: CollectionContext): Promise<informationUnitsResponseItem[]> {
46
+ if (!context.rootNode.childNodes[0]) {
47
+ return [];
48
+ }
49
+ const directoryId = context.rootNode.childNodes[0].shortId;
50
+ const response = await this.directoryNodeService.getItem(directoryId);
51
+
52
+ const infoId = response.informationUnits[0]?.shortId as string
53
+ const childInformationUnit = await this.informationService.getItem({
54
+ id: infoId
55
+ });
56
+
57
+ const versions = await this.informationService.getList({
58
+ restrict: [`versionOf.shortId=${childInformationUnit.versionOf.shortId}`],
59
+ fields: ["renditions", "class", "languages", "labels"],
60
+ })
61
+
62
+ return versions.items;
63
+ }
64
+
36
65
  private async getAttachments(context: CollectionContext): Promise<DocumentsType> {
37
66
  const rootNodeInfoID = context.rootNode.informationUnits[0]?.shortId as string
38
67
  const childInformationUnit = await this.informationService.getItem({
@@ -1,5 +1,5 @@
1
1
  import { BaseArticleCollector } from './BaseArticleCollector';
2
- import { CollectionContext } from "@c-rex/interfaces";
2
+ import { CollectionContext, informationUnitsResponseItem } from "@c-rex/interfaces";
3
3
  import { RenditionsService } from "@c-rex/services";
4
4
  import { DocumentsType } from '@c-rex/types';
5
5
  import { getFileRenditions } from '@c-rex/utils';
@@ -18,12 +18,34 @@ export class TopicArticleCollector extends BaseArticleCollector {
18
18
  }
19
19
 
20
20
  protected async getHtmlContent(context: CollectionContext): Promise<string> {
21
- // Topic-specific HTML source
22
21
  return await this.renditionService.getHTMLRendition({
23
22
  renditions: context.informationUnitsItem.renditions
24
23
  });
25
24
  }
26
25
 
26
+ protected async getDocumentVersions(context: CollectionContext): Promise<informationUnitsResponseItem[]> {
27
+ const rootNodeInfoID = context.rootNode.informationUnits[0]?.shortId as string
28
+ const childInformationUnit = await this.informationService.getItem({
29
+ id: rootNodeInfoID
30
+ });
31
+
32
+ const versions = await this.informationService.getList({
33
+ restrict: [`versionOf.shortId=${childInformationUnit.versionOf.shortId}`],
34
+ fields: ["renditions", "class", "languages", "labels"],
35
+ })
36
+
37
+ return versions.items;
38
+ }
39
+
40
+ protected async getArticleVersions(context: CollectionContext): Promise<informationUnitsResponseItem[]> {
41
+ const versions = await this.informationService.getList({
42
+ restrict: [`versionOf.shortId=${context.informationUnitsItem.versionOf.shortId}`],
43
+ fields: ["renditions", "class", "languages", "labels"],
44
+ })
45
+
46
+ return versions.items;
47
+ }
48
+
27
49
  private async getAttachments(context: CollectionContext): Promise<DocumentsType> {
28
50
  const rootNodeInfoID = context.rootNode.informationUnits[0]?.shortId as string
29
51
  const childInformationUnit = await this.informationService.getItem({
@@ -1,6 +1,6 @@
1
1
  import { HomePage } from "./page";
2
2
  import { PageWrapper } from "@c-rex/components/page-wrapper";
3
- import { WildCardType } from "@c-rex/types";
3
+ import { OperatorType, WildCardType } from "@c-rex/types";
4
4
  import { InformationUnitsService } from "@c-rex/services";
5
5
  import { informationUnitsResponse } from "@c-rex/interfaces";
6
6
  import { SearchProvider } from "@c-rex/contexts/search";
@@ -48,7 +48,7 @@ export const HomeLayout = async ({ searchParams }: HomeProps) => {
48
48
  languages: language.split(","),
49
49
  wildcard: wildcard as WildCardType,
50
50
  restrict: restrict,
51
- operator: operator,
51
+ operator: operator as OperatorType,
52
52
  like: Boolean(like === "true"),
53
53
  filters: filters,
54
54
  tags: config.search.tags,
package/src/home/page.tsx CHANGED
@@ -38,7 +38,6 @@ export const HomePage: FC<HomePageProps> = ({ data }) => {
38
38
  const { setLoading } = useSearchContext();
39
39
  const device = useBreakpoint();
40
40
  const isMobile = device === DEVICE_OPTIONS.MOBILE;
41
- const [disabled, setDisabled] = useState<boolean>(false)
42
41
  const [open, setOpen] = useState<boolean>(false)
43
42
  const [params, setParams] = useQueryStates({
44
43
  language: parseAsString,
@@ -83,6 +82,12 @@ export const HomePage: FC<HomePageProps> = ({ data }) => {
83
82
  }
84
83
  })
85
84
  })
85
+ } else {
86
+ Object.keys(newTags).forEach((key) => {
87
+ newTags[key].forEach((el: any) => {
88
+ el.active = false
89
+ })
90
+ })
86
91
  }
87
92
 
88
93
  if (params.packages !== null && newTags["packages"]) {
@@ -99,7 +104,7 @@ export const HomePage: FC<HomePageProps> = ({ data }) => {
99
104
  }, [data, params]);
100
105
 
101
106
  const filters = useMemo(() => {
102
- if (!tags) return [];
107
+ if (!tags || params.search.length === 0) return [];
103
108
 
104
109
  const filters: filterModel[] = [{
105
110
  key: "operator",
@@ -181,13 +186,6 @@ export const HomePage: FC<HomePageProps> = ({ data }) => {
181
186
  return filters
182
187
  }, [tags, params]);
183
188
 
184
- useEffect(() => {
185
- if (params.search.length == 0) {
186
- setDisabled(true)
187
- return
188
- }
189
- }, [data, params])
190
-
191
189
  useEffect(() => setLoading(false), [data])
192
190
 
193
191
  const updateFilterParam = (key: string, item: any) => {
@@ -258,7 +256,7 @@ export const HomePage: FC<HomePageProps> = ({ data }) => {
258
256
  </div>
259
257
  <DialogFilter
260
258
  trigger={(
261
- <Button variant="default" disabled={disabled}>
259
+ <Button variant="default">
262
260
  <span className="hidden sm:inline">
263
261
  {t("searchSettings")}
264
262
  </span>
@@ -1,45 +0,0 @@
1
- import { BaseArticleCollector } from './BaseArticleCollector';
2
- import { CollectionContext, CollectionResult } from "@c-rex/interfaces";
3
- import { RenditionsService } from "@c-rex/services";
4
-
5
- export class BlogArticleCollector extends BaseArticleCollector {
6
- private renditionService = new RenditionsService();
7
-
8
- protected configureTasks(): void {
9
- this.withVersions()
10
- .withHtmlContent()
11
- .withCustomTask('metadata', this.getBlogMetadata.bind(this))
12
- .withCustomTask('tags', this.getBlogTags.bind(this));
13
- }
14
-
15
- protected async getHtmlContent(context: CollectionContext): Promise<string> {
16
- return await this.renditionService.getHTMLRendition({
17
- renditions: context.informationUnitsItem.renditions
18
- });
19
- }
20
-
21
- // Blog-specific methods
22
- private async getBlogMetadata(context: CollectionContext) {
23
- // Blog-specific metadata logic
24
- return {
25
- author: context.informationUnitsItem.authors?.[0],
26
- publishDate: context.informationUnitsItem.publishDate,
27
- categories: context.informationUnitsItem.categories
28
- };
29
- }
30
-
31
- private async getBlogTags(context: CollectionContext) {
32
- // Blog-specific tags logic
33
- return context.informationUnitsItem.tags || [];
34
- }
35
-
36
- protected buildResult(context: CollectionContext, data: Record<string, any>): CollectionResult {
37
- return {
38
- ...super.buildResult(context, data),
39
- metadata: data.metadata,
40
- tags: data.tags,
41
- // Blog não precisa de document
42
- document: undefined
43
- };
44
- }
45
- }