@redneckz/wildless-cms-uni-blocks 0.14.843 → 0.14.845

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 (37) hide show
  1. package/bundle/bundle.umd.js +9 -8
  2. package/bundle/bundle.umd.min.js +1 -1
  3. package/dist/components/Headline/Headline.js +1 -1
  4. package/dist/components/Headline/Headline.js.map +1 -1
  5. package/dist/services/search/useSearch.js +8 -5
  6. package/dist/services/search/useSearch.js.map +1 -1
  7. package/dist/ui-kit/BaseTile/BaseTile.js +1 -1
  8. package/dist/ui-kit/BaseTile/BaseTile.js.map +1 -1
  9. package/lib/common.css +1 -1
  10. package/lib/components/Headline/Headline.js +1 -1
  11. package/lib/components/Headline/Headline.js.map +1 -1
  12. package/lib/services/search/useSearch.js +8 -5
  13. package/lib/services/search/useSearch.js.map +1 -1
  14. package/lib/ui-kit/BaseTile/BaseTile.js +1 -1
  15. package/lib/ui-kit/BaseTile/BaseTile.js.map +1 -1
  16. package/mobile/bundle/bundle.umd.js +3 -3
  17. package/mobile/bundle/bundle.umd.min.js +1 -1
  18. package/mobile/dist/components/Headline/Headline.js +1 -1
  19. package/mobile/dist/components/Headline/Headline.js.map +1 -1
  20. package/mobile/dist/services/search/useSearch.js +8 -5
  21. package/mobile/dist/services/search/useSearch.js.map +1 -1
  22. package/mobile/dist/ui-kit/BaseTile/BaseTile.js +1 -1
  23. package/mobile/dist/ui-kit/BaseTile/BaseTile.js.map +1 -1
  24. package/mobile/lib/common.css +1 -1
  25. package/mobile/lib/components/Headline/Headline.js +1 -1
  26. package/mobile/lib/components/Headline/Headline.js.map +1 -1
  27. package/mobile/lib/services/search/useSearch.js +8 -5
  28. package/mobile/lib/services/search/useSearch.js.map +1 -1
  29. package/mobile/lib/ui-kit/BaseTile/BaseTile.js +1 -1
  30. package/mobile/lib/ui-kit/BaseTile/BaseTile.js.map +1 -1
  31. package/mobile/src/components/Headline/Headline.tsx +1 -1
  32. package/mobile/src/services/search/useSearch.ts +33 -22
  33. package/mobile/src/ui-kit/BaseTile/BaseTile.tsx +1 -1
  34. package/package.json +1 -1
  35. package/src/components/Headline/Headline.tsx +1 -1
  36. package/src/services/search/useSearch.ts +33 -22
  37. package/src/ui-kit/BaseTile/BaseTile.tsx +1 -1
@@ -1,6 +1,8 @@
1
1
  import { useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
2
2
  import { useAsyncData } from '@redneckz/uni-jsx/lib/hooks/useAsyncData';
3
3
  import { useDebouncedEffect } from '@redneckz/uni-jsx/lib/hooks/useDebouncedEffect';
4
+ import { useRouter, type Router } from '../../external/useRouter';
5
+ import { adjustHref } from '../../utils/adjustHref';
4
6
  import { fetchJSON } from '../../utils/fetchJSON';
5
7
  import { type Nullable } from '../../utils/Nullable';
6
8
  import { joinPath } from '../../utils/url';
@@ -28,13 +30,18 @@ export const useSearch = ({
28
30
  }: SearchParams): [SearchResult | null, SearchInputProps] => {
29
31
  const [query, setQuery] = useState(initialQuery || '');
30
32
 
33
+ const router = useRouter();
34
+
31
35
  useEffect(() => {
32
36
  if (initialQuery !== undefined && initialQuery !== null) {
33
37
  setQuery(initialQuery);
34
38
  }
35
39
  }, [initialQuery]);
36
40
 
37
- const { data } = useAsyncData(basePathList?.length ? basePathList : null, fetchSearchIndex);
41
+ const { data } = useAsyncData(
42
+ basePathList?.length ? basePathList : null,
43
+ fetchSearchIndex(router),
44
+ );
38
45
 
39
46
  const [result, setResult] = useState<SearchResult | null>(null);
40
47
 
@@ -47,28 +54,32 @@ export const useSearch = ({
47
54
  return [result, { value: query, onChange: setQuery }];
48
55
  };
49
56
 
50
- const fetchSearchIndex = async (...basePathList: (string | null)[]): Promise<SearchIndex[]> =>
51
- (
52
- await Promise.allSettled(
53
- basePathList.map(async (basePath) => [
54
- basePath,
55
- await fetchJSON(joinPath(basePath, SEARCH_INDEX_FILENAME)),
56
- ]),
57
+ const fetchSearchIndex =
58
+ (router: Router) =>
59
+ async (...basePathList: (string | null)[]): Promise<SearchIndex[]> =>
60
+ (
61
+ await Promise.allSettled(
62
+ basePathList.map(async (basePath) => [
63
+ basePath,
64
+ await fetchJSON(joinPath(basePath, SEARCH_INDEX_FILENAME)),
65
+ ]),
66
+ )
57
67
  )
58
- )
59
- .map((_) => (_.status === 'fulfilled' ? _.value : []) as FetchSearchIndexResult)
60
- .map(getSearchIndex);
68
+ .map((_) => (_.status === 'fulfilled' ? _.value : []) as FetchSearchIndexResult)
69
+ .map(getSearchIndex(router));
61
70
 
62
- const getSearchIndex = ([basePath, result]: FetchSearchIndexResult): SearchIndex => {
63
- if (!result) {
64
- return {};
65
- }
71
+ const getSearchIndex =
72
+ (router: Router) =>
73
+ ([basePath, result]: FetchSearchIndexResult): SearchIndex => {
74
+ if (!result) {
75
+ return {};
76
+ }
66
77
 
67
- return {
68
- ...result,
69
- corpus: result.corpus?.map((_) => ({
70
- ..._,
71
- uri: _.uri === 'index' ? basePath : joinPath(basePath, _.uri),
72
- })),
78
+ return {
79
+ ...result,
80
+ corpus: result.corpus?.map((_) => ({
81
+ ..._,
82
+ uri: _.uri === 'index' ? basePath : adjustHref(router)(_.uri, basePath),
83
+ })),
84
+ };
73
85
  };
74
- };
@@ -94,7 +94,7 @@ export const BaseTile = JSX<BaseTileProps>(
94
94
 
95
95
  const renderMiddleContent = (insetTitle: VNode, children: VNode) =>
96
96
  insetTitle || children ? (
97
- <div className="grow space-y-lg min-w-fit">
97
+ <div className="grow space-y-lg w-fit">
98
98
  {insetTitle}
99
99
  {children}
100
100
  </div>