@redneckz/wildless-cms-uni-blocks 0.8.5 → 0.8.7

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 (169) hide show
  1. package/bundle/bundle.umd.js +38 -43
  2. package/bundle/bundle.umd.min.js +1 -1
  3. package/bundle/components/Footer/Sitemap.d.ts +0 -2
  4. package/bundle/components/Header/Header.fallback.d.ts +1 -2
  5. package/bundle/hooks/useLink.d.ts +6 -5
  6. package/bundle/services/sitemap/fallbackWCMSResource.d.ts +2 -0
  7. package/bundle/services/sitemap/isHrefActive.d.ts +4 -2
  8. package/bundle/services/sitemap/useSWRResource.d.ts +1 -1
  9. package/bundle/utils/url.d.ts +1 -3
  10. package/dist/components/Footer/Footer.fallback.js +3 -6
  11. package/dist/components/Footer/Footer.fallback.js.map +1 -1
  12. package/dist/components/Footer/Sitemap.d.ts +0 -2
  13. package/dist/components/Footer/Sitemap.js +2 -4
  14. package/dist/components/Footer/Sitemap.js.map +1 -1
  15. package/dist/components/Header/Header.fallback.d.ts +1 -2
  16. package/dist/components/Header/Header.fallback.js +2 -7
  17. package/dist/components/Header/Header.fallback.js.map +1 -1
  18. package/dist/hooks/useLink.d.ts +6 -5
  19. package/dist/hooks/useLink.js +26 -18
  20. package/dist/hooks/useLink.js.map +1 -1
  21. package/dist/services/BlockRouter/BlockRouter.js +1 -1
  22. package/dist/services/BlockRouter/BlockRouter.js.map +1 -1
  23. package/dist/services/sitemap/fallbackWCMSResource.d.ts +2 -0
  24. package/dist/services/sitemap/fallbackWCMSResource.js +8 -0
  25. package/dist/services/sitemap/fallbackWCMSResource.js.map +1 -0
  26. package/dist/services/sitemap/isHrefActive.d.ts +4 -2
  27. package/dist/services/sitemap/isHrefActive.js +1 -6
  28. package/dist/services/sitemap/isHrefActive.js.map +1 -1
  29. package/dist/services/sitemap/isTopItemActive.js +4 -1
  30. package/dist/services/sitemap/isTopItemActive.js.map +1 -1
  31. package/dist/services/sitemap/useSWRResource.d.ts +1 -1
  32. package/dist/services/sitemap/useSWRResource.js +2 -2
  33. package/dist/setup-fixture.js +3 -1
  34. package/dist/setup-fixture.js.map +1 -1
  35. package/dist/utils/url.d.ts +1 -3
  36. package/dist/utils/url.js +4 -8
  37. package/dist/utils/url.js.map +1 -1
  38. package/lib/components/Footer/Footer.fallback.js +1 -4
  39. package/lib/components/Footer/Footer.fallback.js.map +1 -1
  40. package/lib/components/Footer/Sitemap.d.ts +0 -2
  41. package/lib/components/Footer/Sitemap.js +2 -4
  42. package/lib/components/Footer/Sitemap.js.map +1 -1
  43. package/lib/components/Header/Header.fallback.d.ts +1 -2
  44. package/lib/components/Header/Header.fallback.js +2 -7
  45. package/lib/components/Header/Header.fallback.js.map +1 -1
  46. package/lib/hooks/useLink.d.ts +6 -5
  47. package/lib/hooks/useLink.js +27 -19
  48. package/lib/hooks/useLink.js.map +1 -1
  49. package/lib/services/BlockRouter/BlockRouter.js +1 -1
  50. package/lib/services/BlockRouter/BlockRouter.js.map +1 -1
  51. package/lib/services/sitemap/fallbackWCMSResource.d.ts +2 -0
  52. package/lib/services/sitemap/fallbackWCMSResource.js +5 -0
  53. package/lib/services/sitemap/fallbackWCMSResource.js.map +1 -0
  54. package/lib/services/sitemap/isHrefActive.d.ts +4 -2
  55. package/lib/services/sitemap/isHrefActive.js +1 -6
  56. package/lib/services/sitemap/isHrefActive.js.map +1 -1
  57. package/lib/services/sitemap/isTopItemActive.js +4 -1
  58. package/lib/services/sitemap/isTopItemActive.js.map +1 -1
  59. package/lib/services/sitemap/useSWRResource.d.ts +1 -1
  60. package/lib/services/sitemap/useSWRResource.js +2 -2
  61. package/lib/setup-fixture.js +3 -1
  62. package/lib/setup-fixture.js.map +1 -1
  63. package/lib/utils/url.d.ts +1 -3
  64. package/lib/utils/url.js +2 -4
  65. package/lib/utils/url.js.map +1 -1
  66. package/mobile/bundle/bundle.umd.js +36 -35
  67. package/mobile/bundle/bundle.umd.min.js +1 -1
  68. package/mobile/bundle/components/Footer/Sitemap.d.ts +0 -2
  69. package/mobile/bundle/components/Header/Header.fallback.d.ts +1 -2
  70. package/mobile/bundle/hooks/useLink.d.ts +6 -5
  71. package/mobile/bundle/services/sitemap/fallbackWCMSResource.d.ts +2 -0
  72. package/mobile/bundle/services/sitemap/isHrefActive.d.ts +4 -2
  73. package/mobile/bundle/services/sitemap/useSWRResource.d.ts +1 -1
  74. package/mobile/bundle/utils/url.d.ts +1 -3
  75. package/mobile/dist/components/Footer/Footer.fallback.js +3 -6
  76. package/mobile/dist/components/Footer/Footer.fallback.js.map +1 -1
  77. package/mobile/dist/components/Footer/Sitemap.d.ts +0 -2
  78. package/mobile/dist/components/Footer/Sitemap.js +2 -4
  79. package/mobile/dist/components/Footer/Sitemap.js.map +1 -1
  80. package/mobile/dist/components/Header/Header.fallback.d.ts +1 -2
  81. package/mobile/dist/components/Header/Header.fallback.js +2 -7
  82. package/mobile/dist/components/Header/Header.fallback.js.map +1 -1
  83. package/mobile/dist/hooks/useLink.d.ts +6 -5
  84. package/mobile/dist/hooks/useLink.js +26 -18
  85. package/mobile/dist/hooks/useLink.js.map +1 -1
  86. package/mobile/dist/services/BlockRouter/BlockRouter.js +1 -1
  87. package/mobile/dist/services/BlockRouter/BlockRouter.js.map +1 -1
  88. package/mobile/dist/services/sitemap/fallbackWCMSResource.d.ts +2 -0
  89. package/mobile/dist/services/sitemap/fallbackWCMSResource.js +8 -0
  90. package/mobile/dist/services/sitemap/fallbackWCMSResource.js.map +1 -0
  91. package/mobile/dist/services/sitemap/isHrefActive.d.ts +4 -2
  92. package/mobile/dist/services/sitemap/isHrefActive.js +1 -6
  93. package/mobile/dist/services/sitemap/isHrefActive.js.map +1 -1
  94. package/mobile/dist/services/sitemap/isTopItemActive.js +4 -1
  95. package/mobile/dist/services/sitemap/isTopItemActive.js.map +1 -1
  96. package/mobile/dist/services/sitemap/useSWRResource.d.ts +1 -1
  97. package/mobile/dist/services/sitemap/useSWRResource.js +2 -2
  98. package/mobile/dist/setup-fixture.js +3 -1
  99. package/mobile/dist/setup-fixture.js.map +1 -1
  100. package/mobile/dist/utils/url.d.ts +1 -3
  101. package/mobile/dist/utils/url.js +4 -8
  102. package/mobile/dist/utils/url.js.map +1 -1
  103. package/mobile/lib/components/Footer/Footer.fallback.js +1 -4
  104. package/mobile/lib/components/Footer/Footer.fallback.js.map +1 -1
  105. package/mobile/lib/components/Footer/Sitemap.d.ts +0 -2
  106. package/mobile/lib/components/Footer/Sitemap.js +2 -4
  107. package/mobile/lib/components/Footer/Sitemap.js.map +1 -1
  108. package/mobile/lib/components/Header/Header.fallback.d.ts +1 -2
  109. package/mobile/lib/components/Header/Header.fallback.js +2 -7
  110. package/mobile/lib/components/Header/Header.fallback.js.map +1 -1
  111. package/mobile/lib/hooks/useLink.d.ts +6 -5
  112. package/mobile/lib/hooks/useLink.js +27 -19
  113. package/mobile/lib/hooks/useLink.js.map +1 -1
  114. package/mobile/lib/services/BlockRouter/BlockRouter.js +1 -1
  115. package/mobile/lib/services/BlockRouter/BlockRouter.js.map +1 -1
  116. package/mobile/lib/services/sitemap/fallbackWCMSResource.d.ts +2 -0
  117. package/mobile/lib/services/sitemap/fallbackWCMSResource.js +5 -0
  118. package/mobile/lib/services/sitemap/fallbackWCMSResource.js.map +1 -0
  119. package/mobile/lib/services/sitemap/isHrefActive.d.ts +4 -2
  120. package/mobile/lib/services/sitemap/isHrefActive.js +1 -6
  121. package/mobile/lib/services/sitemap/isHrefActive.js.map +1 -1
  122. package/mobile/lib/services/sitemap/isTopItemActive.js +4 -1
  123. package/mobile/lib/services/sitemap/isTopItemActive.js.map +1 -1
  124. package/mobile/lib/services/sitemap/useSWRResource.d.ts +1 -1
  125. package/mobile/lib/services/sitemap/useSWRResource.js +2 -2
  126. package/mobile/lib/setup-fixture.js +3 -1
  127. package/mobile/lib/setup-fixture.js.map +1 -1
  128. package/mobile/lib/utils/url.d.ts +1 -3
  129. package/mobile/lib/utils/url.js +2 -4
  130. package/mobile/lib/utils/url.js.map +1 -1
  131. package/mobile/src/components/Footer/Footer.fallback.ts +1 -6
  132. package/mobile/src/components/Footer/Sitemap.tsx +2 -6
  133. package/mobile/src/components/Header/Header.fallback.ts +2 -12
  134. package/mobile/src/hooks/useLink.ts +31 -20
  135. package/mobile/src/services/BlockRouter/BlockRouter.ts +1 -1
  136. package/mobile/src/services/sitemap/fallbackWCMSResource.ts +7 -0
  137. package/mobile/src/services/sitemap/isHrefActive.ts +3 -12
  138. package/mobile/src/services/sitemap/isTopItemActive.ts +4 -1
  139. package/mobile/src/services/sitemap/useSWRResource.ts +2 -2
  140. package/mobile/src/setup-fixture.ts +3 -1
  141. package/mobile/src/utils/url.ts +4 -4
  142. package/package.json +1 -1
  143. package/src/components/Footer/Footer.fallback.ts +1 -6
  144. package/src/components/Footer/Sitemap.tsx +2 -6
  145. package/src/components/Header/Header.fallback.ts +2 -12
  146. package/src/hooks/useLink.ts +31 -20
  147. package/src/services/BlockRouter/BlockRouter.ts +1 -1
  148. package/src/services/sitemap/fallbackWCMSResource.ts +7 -0
  149. package/src/services/sitemap/isHrefActive.ts +3 -12
  150. package/src/services/sitemap/isTopItemActive.ts +4 -1
  151. package/src/services/sitemap/useSWRResource.ts +2 -2
  152. package/src/setup-fixture.ts +3 -1
  153. package/src/utils/url.ts +4 -4
  154. package/bundle/services/sitemap/mergeTopItems.d.ts +0 -2
  155. package/dist/services/sitemap/mergeTopItems.d.ts +0 -2
  156. package/dist/services/sitemap/mergeTopItems.js +0 -8
  157. package/dist/services/sitemap/mergeTopItems.js.map +0 -1
  158. package/lib/services/sitemap/mergeTopItems.d.ts +0 -2
  159. package/lib/services/sitemap/mergeTopItems.js +0 -5
  160. package/lib/services/sitemap/mergeTopItems.js.map +0 -1
  161. package/mobile/bundle/services/sitemap/mergeTopItems.d.ts +0 -2
  162. package/mobile/dist/services/sitemap/mergeTopItems.d.ts +0 -2
  163. package/mobile/dist/services/sitemap/mergeTopItems.js +0 -8
  164. package/mobile/dist/services/sitemap/mergeTopItems.js.map +0 -1
  165. package/mobile/lib/services/sitemap/mergeTopItems.d.ts +0 -2
  166. package/mobile/lib/services/sitemap/mergeTopItems.js +0 -5
  167. package/mobile/lib/services/sitemap/mergeTopItems.js.map +0 -1
  168. package/mobile/src/services/sitemap/mergeTopItems.ts +0 -12
  169. package/src/services/sitemap/mergeTopItems.ts +0 -12
@@ -1,3 +1,6 @@
1
+ import { projectSettings } from '../../ProjectSettings.js';
1
2
  import { isHrefActive } from './isHrefActive.js';
2
- export const isTopItemActive = (router) => (topItem) => topItem.items?.some(isHrefActive(router)) || isHrefActive(router)(topItem);
3
+ export const isTopItemActive = (router) => (topItem) => projectSettings.BASE_PATH
4
+ ? isHrefActive({ pathname: projectSettings.BASE_PATH })(topItem)
5
+ : topItem.items?.some(isHrefActive(router)) || isHrefActive(router)(topItem);
3
6
  //# sourceMappingURL=isTopItemActive.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"isTopItemActive.js","sourceRoot":"","sources":["../../../src/services/sitemap/isTopItemActive.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,MAAM,CAAC,MAAM,eAAe,GAC1B,CAAC,MAAc,EAAE,EAAE,CACnB,CAAC,OAAoB,EAAW,EAAE,CAChC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC"}
1
+ {"version":3,"file":"isTopItemActive.js","sourceRoot":"","sources":["../../../src/services/sitemap/isTopItemActive.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,MAAM,CAAC,MAAM,eAAe,GAC1B,CAAC,MAAc,EAAE,EAAE,CACnB,CAAC,OAAoB,EAAW,EAAE,CAChC,eAAe,CAAC,SAAS;IACvB,CAAC,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,eAAe,CAAC,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC;IAChE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC"}
@@ -1,2 +1,2 @@
1
1
  import type { Fallback } from '../../model/Fallback';
2
- export declare function useSWRResource<Data>(fileName: string, fallback?: Fallback): Data;
2
+ export declare function useSWRResource<Data>(filename: string, fallback?: Fallback): Data;
@@ -1,7 +1,7 @@
1
1
  import { useAsyncData } from '@redneckz/uni-jsx/lib/hooks/useAsyncData';
2
2
  import { fetchJSONUnsafe } from '../../utils/fetchJSON.js';
3
- export function useSWRResource(fileName, fallback = {}) {
4
- const { data } = useAsyncData(`/wcms-resources/${fileName}.json`, fetchJSONUnsafe, {
3
+ export function useSWRResource(filename, fallback = {}) {
4
+ const { data } = useAsyncData(`/wcms-resources/${filename}.json`, fetchJSONUnsafe, {
5
5
  fallback,
6
6
  });
7
7
  return data || {};
@@ -18,7 +18,9 @@ useRouter.setup(() => {
18
18
  }, []);
19
19
  return {
20
20
  href,
21
- pathname: '',
21
+ pathname: projectSettings.BASE_PATH
22
+ ? new URL(href).pathname.substring(projectSettings.BASE_PATH.length - 1)
23
+ : '',
22
24
  query: {},
23
25
  push: (url) => {
24
26
  globalThis.history.pushState(null, '', url);
@@ -1 +1 @@
1
- {"version":3,"file":"setup-fixture.js","sourceRoot":"","sources":["../src/setup-fixture.ts"],"names":[],"mappings":"AAAA,OAAO,mCAAmC,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB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C,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,EAAE,CAAC,GAAW,EAAE,EAAE;YACvB,UAAU,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;QACjD,CAAC;KACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,KAAK,CAAC,CAAC,OAAO,EAAO,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE;IAC9C,EAAE,CAAC,cAAc,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,CAAC,CAAC;AACd,CAAC,CAAC,CAAC"}
@@ -3,6 +3,4 @@ export declare const isURL: (href?: string) => href is `${string}//${string}`;
3
3
  export declare const isLocalURL: (href: string | undefined, target?: Target) => boolean;
4
4
  export declare const isHash: (href?: string) => href is `#${string}`;
5
5
  export declare const withoutQuery: (href?: string) => string;
6
- export declare const getOrigin: (href?: string) => string | undefined;
7
- export declare const getPathname: (href?: string) => string | undefined;
8
- export declare const getHash: (href?: string) => string | undefined;
6
+ export declare const joinPath: (...path: string[]) => string;
@@ -1,8 +1,6 @@
1
1
  export const isURL = (href) => Boolean(href?.includes('//'));
2
2
  export const isLocalURL = (href, target) => Boolean(href && !isURL(href) && (!target || target === '_self'));
3
3
  export const isHash = (href) => Boolean(href?.startsWith('#'));
4
- export const withoutQuery = (href) => (href || '').replace(/\/?\?.*/, '');
5
- export const getOrigin = (href) => (isURL(href) ? new URL(href).origin : undefined);
6
- export const getPathname = (href) => (isURL(href) ? new URL(href).pathname : undefined);
7
- export const getHash = (href) => (isURL(href) ? new URL(href).hash : undefined);
4
+ export const withoutQuery = (href) => (href || '').replace(/\?.*/, '').replace(/\/$/, '');
5
+ export const joinPath = (...path) => path.filter(Boolean).join('/').replace(/\/+/g, '/');
8
6
  //# sourceMappingURL=url.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/utils/url.ts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":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,IAAa,EAAkC,EAAE,CACrE,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AAEhC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAwB,EAAE,MAAe,EAAE,EAAE,CACtE,OAAO,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC;AAEnE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,IAAa,EAAwB,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;AAE9F,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAa,EAAU,EAAE,CACpD,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAEtD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAc,EAAU,EAAE,CACpD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC"}
@@ -1,13 +1,8 @@
1
- import { readFile } from 'fs/promises';
2
1
  import type { FallbackMap } from '../../model/Fallback';
3
2
  import { projectSettings } from '../../ProjectSettings';
3
+ import { fallbackWCMSResource } from '../../services/sitemap/fallbackWCMSResource';
4
4
 
5
5
  export const fallback = (): FallbackMap => ({
6
6
  ...fallbackWCMSResource(projectSettings.SITEMAP || 'sitemap'),
7
7
  ...fallbackWCMSResource(projectSettings.FOOTER || 'footer'),
8
8
  });
9
-
10
- const fallbackWCMSResource = (filename: string): FallbackMap => ({
11
- [filename]: async () =>
12
- JSON.parse(await readFile(`./content/wcms-resources/${filename}.json`, 'utf-8')),
13
- });
@@ -3,25 +3,21 @@ import { useLink } from '../../hooks/useLink';
3
3
  import type { Fallback } from '../../model/Fallback';
4
4
  import type { LinkProps } from '../../model/LinkProps';
5
5
  import { projectSettings } from '../../ProjectSettings';
6
- import { mergeTopItems } from '../../services/sitemap/mergeTopItems';
7
6
  import type { SitemapDataProps, TopMenuItem } from '../../services/sitemap/SitemapProps';
8
7
  import { useSWRResource } from '../../services/sitemap/useSWRResource';
9
8
 
10
9
  export interface SitemapProps {
11
10
  className?: string;
12
- items?: TopMenuItem[];
13
11
  fallback?: Fallback;
14
12
  }
15
13
 
16
- export const Sitemap = JSX<SitemapProps>(({ className = '', items, fallback }) => {
14
+ export const Sitemap = JSX<SitemapProps>(({ className = '', fallback }) => {
17
15
  const link = useLink();
18
-
19
16
  const sitemap = useSWRResource<SitemapDataProps>(projectSettings.SITEMAP || 'sitemap', fallback);
20
- const mergedItems = mergeTopItems(sitemap.topItems, items);
21
17
 
22
18
  return (
23
19
  <div className={`flex flex-grow items-start justify-between gap-[54px] xl:gap-5 ${className}`}>
24
- {mergedItems?.map((_, i) => renderColumn(link(_), i))}
20
+ {sitemap.topItems?.map((_, i) => renderColumn(link(_), i))}
25
21
  </div>
26
22
  );
27
23
  });
@@ -1,14 +1,4 @@
1
- import { readFile } from 'fs/promises';
2
1
  import { projectSettings } from '../../ProjectSettings';
3
- import type { FallbackMap } from '../../model/Fallback';
2
+ import { fallbackWCMSResource } from '../../services/sitemap/fallbackWCMSResource';
4
3
 
5
- export const fallback = (): FallbackMap => ({
6
- [`/wcms-resources/${projectSettings.SITEMAP || 'sitemap'}.json`]: async () => {
7
- const data = await readFile(
8
- `./content/wcms-resources/${projectSettings.SITEMAP || 'sitemap'}.json`,
9
- 'utf-8',
10
- );
11
-
12
- return JSON.parse(data);
13
- },
14
- });
4
+ export const fallback = () => fallbackWCMSResource(projectSettings.SITEMAP || 'sitemap');
@@ -1,23 +1,43 @@
1
- import type { LinkProps, Target } from '../model/LinkProps';
1
+ import type { LinkProps } from '../model/LinkProps';
2
+ import { projectSettings } from '../ProjectSettings';
2
3
  import { useBlockRouter } from '../services/BlockRouter/useBlockRouter';
3
- import { isHash, isLocalURL } from '../utils/url';
4
+ import { isHash, isLocalURL, joinPath } from '../utils/url';
4
5
  import { handlerDecorator } from './handlerDecorator';
5
6
  import { useRouter } from './useRouter';
6
7
 
7
- interface ClickHandler {
8
- onClick(ev?: { preventDefault: () => void }): void;
8
+ interface PreventableEvent {
9
+ preventDefault: () => void;
9
10
  }
10
11
 
11
- export function useLink(
12
- isRemote?: boolean,
13
- ): <L extends Partial<LinkProps & ClickHandler>>(props: L) => L & ClickHandler {
12
+ interface Clickable {
13
+ onClick(ev?: PreventableEvent): void;
14
+ }
15
+
16
+ export function useLink(isRemote?: boolean) {
14
17
  const router = useRouter();
15
18
  const blockRouter = useBlockRouter();
16
19
 
17
- const handleLocalURL =
18
- (href: string | undefined, target?: Target) => (ev?: { preventDefault: () => void }) => {
20
+ return <L extends Partial<LinkProps & Clickable>>(props: L): L & Clickable => ({
21
+ ...props,
22
+ href: adjustHref(props.href),
23
+ 'aria-label': props.text,
24
+ onClick: handlerDecorator(handleHref(props), props),
25
+ });
26
+
27
+ function adjustHref(href: string | undefined) {
28
+ const isRelativeToBase = !isRemote && href?.startsWith('/');
29
+
30
+ return projectSettings.BASE_PATH && href && isRelativeToBase
31
+ ? joinPath(projectSettings.BASE_PATH, href)
32
+ : href;
33
+ }
34
+
35
+ function handleHref({ href, target, onClick }: Partial<LinkProps & Clickable>) {
36
+ return (ev?: PreventableEvent) => {
37
+ onClick && onClick(ev);
38
+
19
39
  if (isRemote || !isLocalURL(href, target)) {
20
- // Proceed with native handle
40
+ // Default routing
21
41
  return;
22
42
  }
23
43
 
@@ -29,14 +49,5 @@ export function useLink(
29
49
  router.push(href);
30
50
  }
31
51
  };
32
-
33
- return (props) => ({
34
- ...props,
35
- 'aria-label': props.text,
36
- onClick: handlerDecorator((ev?: { preventDefault: () => void }) => {
37
- props.onClick && props.onClick(ev);
38
-
39
- handleLocalURL(props.href, props.target)(ev);
40
- }, props),
41
- });
52
+ }
42
53
  }
@@ -15,7 +15,7 @@ interface EventMap {
15
15
  intersection: BlockIntersectionEvent;
16
16
  }
17
17
 
18
- const normalizeAnchor = (rawAnchor?: string) => rawAnchor?.replace('#', '');
18
+ const normalizeAnchor = (rawAnchor?: string) => rawAnchor?.replace('#', '') || '';
19
19
  const getURLWithAnchor = (rawAnchor?: string) =>
20
20
  `${globalThis.location?.pathname}#${normalizeAnchor(rawAnchor)}`;
21
21
 
@@ -0,0 +1,7 @@
1
+ import { readFile } from 'fs/promises';
2
+ import type { FallbackMap } from '../../model/Fallback';
3
+
4
+ export const fallbackWCMSResource = (filename: string): FallbackMap => ({
5
+ [`/wcms-resources/${filename}.json`]: async () =>
6
+ JSON.parse(await readFile(`./content/wcms-resources/${filename}.json`, 'utf-8')),
7
+ });
@@ -1,15 +1,6 @@
1
- import type { Router } from '../../hooks/useRouter';
2
- import { projectSettings } from '../../ProjectSettings';
3
1
  import { isURL, withoutQuery } from '../../utils/url';
4
2
 
5
3
  export const isHrefActive =
6
- (router: Router) =>
7
- ({ href }: { href?: string }): boolean => {
8
- const { BASE_PATH } = projectSettings;
9
- const relativeHref =
10
- BASE_PATH && href?.startsWith(BASE_PATH) ? href.substring(BASE_PATH.length) : href;
11
-
12
- return withoutQuery(isURL(href) ? router.href : router.pathname).startsWith(
13
- withoutQuery(relativeHref),
14
- );
15
- };
4
+ (router: { href?: string; pathname: string }) =>
5
+ ({ href }: { href?: string }): boolean =>
6
+ withoutQuery(isURL(href) ? router.href : router.pathname).startsWith(withoutQuery(href));
@@ -1,8 +1,11 @@
1
1
  import type { Router } from '../../hooks/useRouter';
2
+ import { projectSettings } from '../../ProjectSettings';
2
3
  import { isHrefActive } from './isHrefActive';
3
4
  import { TopMenuItem } from './SitemapProps';
4
5
 
5
6
  export const isTopItemActive =
6
7
  (router: Router) =>
7
8
  (topItem: TopMenuItem): boolean =>
8
- topItem.items?.some(isHrefActive(router)) || isHrefActive(router)(topItem);
9
+ projectSettings.BASE_PATH
10
+ ? isHrefActive({ pathname: projectSettings.BASE_PATH })(topItem)
11
+ : topItem.items?.some(isHrefActive(router)) || isHrefActive(router)(topItem);
@@ -2,8 +2,8 @@ import { useAsyncData } from '@redneckz/uni-jsx/lib/hooks/useAsyncData';
2
2
  import type { Fallback } from '../../model/Fallback';
3
3
  import { fetchJSONUnsafe } from '../../utils/fetchJSON';
4
4
 
5
- export function useSWRResource<Data>(fileName: string, fallback: Fallback = {}): Data {
6
- const { data } = useAsyncData<Data>(`/wcms-resources/${fileName}.json`, fetchJSONUnsafe, {
5
+ export function useSWRResource<Data>(filename: string, fallback: Fallback = {}): Data {
6
+ const { data } = useAsyncData<Data>(`/wcms-resources/${filename}.json`, fetchJSONUnsafe, {
7
7
  fallback,
8
8
  });
9
9
 
@@ -26,7 +26,9 @@ useRouter.setup(() => {
26
26
 
27
27
  return {
28
28
  href,
29
- pathname: '',
29
+ pathname: projectSettings.BASE_PATH
30
+ ? new URL(href).pathname.substring(projectSettings.BASE_PATH.length - 1)
31
+ : '',
30
32
  query: {},
31
33
  push: (url: string) => {
32
34
  globalThis.history.pushState(null, '', url);
@@ -8,8 +8,8 @@ export const isLocalURL = (href: string | undefined, target?: Target) =>
8
8
 
9
9
  export const isHash = (href?: string): href is `#${string}` => Boolean(href?.startsWith('#'));
10
10
 
11
- export const withoutQuery = (href?: string): string => (href || '').replace(/\/?\?.*/, '');
11
+ export const withoutQuery = (href?: string): string =>
12
+ (href || '').replace(/\?.*/, '').replace(/\/$/, '');
12
13
 
13
- export const getOrigin = (href?: string) => (isURL(href) ? new URL(href).origin : undefined);
14
- export const getPathname = (href?: string) => (isURL(href) ? new URL(href).pathname : undefined);
15
- export const getHash = (href?: string) => (isURL(href) ? new URL(href).hash : undefined);
14
+ export const joinPath = (...path: string[]): string =>
15
+ path.filter(Boolean).join('/').replace(/\/+/g, '/');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.8.5",
3
+ "version": "0.8.7",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -1,13 +1,8 @@
1
- import { readFile } from 'fs/promises';
2
1
  import type { FallbackMap } from '../../model/Fallback';
3
2
  import { projectSettings } from '../../ProjectSettings';
3
+ import { fallbackWCMSResource } from '../../services/sitemap/fallbackWCMSResource';
4
4
 
5
5
  export const fallback = (): FallbackMap => ({
6
6
  ...fallbackWCMSResource(projectSettings.SITEMAP || 'sitemap'),
7
7
  ...fallbackWCMSResource(projectSettings.FOOTER || 'footer'),
8
8
  });
9
-
10
- const fallbackWCMSResource = (filename: string): FallbackMap => ({
11
- [filename]: async () =>
12
- JSON.parse(await readFile(`./content/wcms-resources/${filename}.json`, 'utf-8')),
13
- });
@@ -3,25 +3,21 @@ import { useLink } from '../../hooks/useLink';
3
3
  import type { Fallback } from '../../model/Fallback';
4
4
  import type { LinkProps } from '../../model/LinkProps';
5
5
  import { projectSettings } from '../../ProjectSettings';
6
- import { mergeTopItems } from '../../services/sitemap/mergeTopItems';
7
6
  import type { SitemapDataProps, TopMenuItem } from '../../services/sitemap/SitemapProps';
8
7
  import { useSWRResource } from '../../services/sitemap/useSWRResource';
9
8
 
10
9
  export interface SitemapProps {
11
10
  className?: string;
12
- items?: TopMenuItem[];
13
11
  fallback?: Fallback;
14
12
  }
15
13
 
16
- export const Sitemap = JSX<SitemapProps>(({ className = '', items, fallback }) => {
14
+ export const Sitemap = JSX<SitemapProps>(({ className = '', fallback }) => {
17
15
  const link = useLink();
18
-
19
16
  const sitemap = useSWRResource<SitemapDataProps>(projectSettings.SITEMAP || 'sitemap', fallback);
20
- const mergedItems = mergeTopItems(sitemap.topItems, items);
21
17
 
22
18
  return (
23
19
  <div className={`flex flex-grow items-start justify-between gap-[54px] xl:gap-5 ${className}`}>
24
- {mergedItems?.map((_, i) => renderColumn(link(_), i))}
20
+ {sitemap.topItems?.map((_, i) => renderColumn(link(_), i))}
25
21
  </div>
26
22
  );
27
23
  });
@@ -1,14 +1,4 @@
1
- import { readFile } from 'fs/promises';
2
1
  import { projectSettings } from '../../ProjectSettings';
3
- import type { FallbackMap } from '../../model/Fallback';
2
+ import { fallbackWCMSResource } from '../../services/sitemap/fallbackWCMSResource';
4
3
 
5
- export const fallback = (): FallbackMap => ({
6
- [`/wcms-resources/${projectSettings.SITEMAP || 'sitemap'}.json`]: async () => {
7
- const data = await readFile(
8
- `./content/wcms-resources/${projectSettings.SITEMAP || 'sitemap'}.json`,
9
- 'utf-8',
10
- );
11
-
12
- return JSON.parse(data);
13
- },
14
- });
4
+ export const fallback = () => fallbackWCMSResource(projectSettings.SITEMAP || 'sitemap');
@@ -1,23 +1,43 @@
1
- import type { LinkProps, Target } from '../model/LinkProps';
1
+ import type { LinkProps } from '../model/LinkProps';
2
+ import { projectSettings } from '../ProjectSettings';
2
3
  import { useBlockRouter } from '../services/BlockRouter/useBlockRouter';
3
- import { isHash, isLocalURL } from '../utils/url';
4
+ import { isHash, isLocalURL, joinPath } from '../utils/url';
4
5
  import { handlerDecorator } from './handlerDecorator';
5
6
  import { useRouter } from './useRouter';
6
7
 
7
- interface ClickHandler {
8
- onClick(ev?: { preventDefault: () => void }): void;
8
+ interface PreventableEvent {
9
+ preventDefault: () => void;
9
10
  }
10
11
 
11
- export function useLink(
12
- isRemote?: boolean,
13
- ): <L extends Partial<LinkProps & ClickHandler>>(props: L) => L & ClickHandler {
12
+ interface Clickable {
13
+ onClick(ev?: PreventableEvent): void;
14
+ }
15
+
16
+ export function useLink(isRemote?: boolean) {
14
17
  const router = useRouter();
15
18
  const blockRouter = useBlockRouter();
16
19
 
17
- const handleLocalURL =
18
- (href: string | undefined, target?: Target) => (ev?: { preventDefault: () => void }) => {
20
+ return <L extends Partial<LinkProps & Clickable>>(props: L): L & Clickable => ({
21
+ ...props,
22
+ href: adjustHref(props.href),
23
+ 'aria-label': props.text,
24
+ onClick: handlerDecorator(handleHref(props), props),
25
+ });
26
+
27
+ function adjustHref(href: string | undefined) {
28
+ const isRelativeToBase = !isRemote && href?.startsWith('/');
29
+
30
+ return projectSettings.BASE_PATH && href && isRelativeToBase
31
+ ? joinPath(projectSettings.BASE_PATH, href)
32
+ : href;
33
+ }
34
+
35
+ function handleHref({ href, target, onClick }: Partial<LinkProps & Clickable>) {
36
+ return (ev?: PreventableEvent) => {
37
+ onClick && onClick(ev);
38
+
19
39
  if (isRemote || !isLocalURL(href, target)) {
20
- // Proceed with native handle
40
+ // Default routing
21
41
  return;
22
42
  }
23
43
 
@@ -29,14 +49,5 @@ export function useLink(
29
49
  router.push(href);
30
50
  }
31
51
  };
32
-
33
- return (props) => ({
34
- ...props,
35
- 'aria-label': props.text,
36
- onClick: handlerDecorator((ev?: { preventDefault: () => void }) => {
37
- props.onClick && props.onClick(ev);
38
-
39
- handleLocalURL(props.href, props.target)(ev);
40
- }, props),
41
- });
52
+ }
42
53
  }
@@ -15,7 +15,7 @@ interface EventMap {
15
15
  intersection: BlockIntersectionEvent;
16
16
  }
17
17
 
18
- const normalizeAnchor = (rawAnchor?: string) => rawAnchor?.replace('#', '');
18
+ const normalizeAnchor = (rawAnchor?: string) => rawAnchor?.replace('#', '') || '';
19
19
  const getURLWithAnchor = (rawAnchor?: string) =>
20
20
  `${globalThis.location?.pathname}#${normalizeAnchor(rawAnchor)}`;
21
21
 
@@ -0,0 +1,7 @@
1
+ import { readFile } from 'fs/promises';
2
+ import type { FallbackMap } from '../../model/Fallback';
3
+
4
+ export const fallbackWCMSResource = (filename: string): FallbackMap => ({
5
+ [`/wcms-resources/${filename}.json`]: async () =>
6
+ JSON.parse(await readFile(`./content/wcms-resources/${filename}.json`, 'utf-8')),
7
+ });
@@ -1,15 +1,6 @@
1
- import type { Router } from '../../hooks/useRouter';
2
- import { projectSettings } from '../../ProjectSettings';
3
1
  import { isURL, withoutQuery } from '../../utils/url';
4
2
 
5
3
  export const isHrefActive =
6
- (router: Router) =>
7
- ({ href }: { href?: string }): boolean => {
8
- const { BASE_PATH } = projectSettings;
9
- const relativeHref =
10
- BASE_PATH && href?.startsWith(BASE_PATH) ? href.substring(BASE_PATH.length) : href;
11
-
12
- return withoutQuery(isURL(href) ? router.href : router.pathname).startsWith(
13
- withoutQuery(relativeHref),
14
- );
15
- };
4
+ (router: { href?: string; pathname: string }) =>
5
+ ({ href }: { href?: string }): boolean =>
6
+ withoutQuery(isURL(href) ? router.href : router.pathname).startsWith(withoutQuery(href));
@@ -1,8 +1,11 @@
1
1
  import type { Router } from '../../hooks/useRouter';
2
+ import { projectSettings } from '../../ProjectSettings';
2
3
  import { isHrefActive } from './isHrefActive';
3
4
  import { TopMenuItem } from './SitemapProps';
4
5
 
5
6
  export const isTopItemActive =
6
7
  (router: Router) =>
7
8
  (topItem: TopMenuItem): boolean =>
8
- topItem.items?.some(isHrefActive(router)) || isHrefActive(router)(topItem);
9
+ projectSettings.BASE_PATH
10
+ ? isHrefActive({ pathname: projectSettings.BASE_PATH })(topItem)
11
+ : topItem.items?.some(isHrefActive(router)) || isHrefActive(router)(topItem);
@@ -2,8 +2,8 @@ import { useAsyncData } from '@redneckz/uni-jsx/lib/hooks/useAsyncData';
2
2
  import type { Fallback } from '../../model/Fallback';
3
3
  import { fetchJSONUnsafe } from '../../utils/fetchJSON';
4
4
 
5
- export function useSWRResource<Data>(fileName: string, fallback: Fallback = {}): Data {
6
- const { data } = useAsyncData<Data>(`/wcms-resources/${fileName}.json`, fetchJSONUnsafe, {
5
+ export function useSWRResource<Data>(filename: string, fallback: Fallback = {}): Data {
6
+ const { data } = useAsyncData<Data>(`/wcms-resources/${filename}.json`, fetchJSONUnsafe, {
7
7
  fallback,
8
8
  });
9
9
 
@@ -26,7 +26,9 @@ useRouter.setup(() => {
26
26
 
27
27
  return {
28
28
  href,
29
- pathname: '',
29
+ pathname: projectSettings.BASE_PATH
30
+ ? new URL(href).pathname.substring(projectSettings.BASE_PATH.length - 1)
31
+ : '',
30
32
  query: {},
31
33
  push: (url: string) => {
32
34
  globalThis.history.pushState(null, '', url);
package/src/utils/url.ts CHANGED
@@ -8,8 +8,8 @@ export const isLocalURL = (href: string | undefined, target?: Target) =>
8
8
 
9
9
  export const isHash = (href?: string): href is `#${string}` => Boolean(href?.startsWith('#'));
10
10
 
11
- export const withoutQuery = (href?: string): string => (href || '').replace(/\/?\?.*/, '');
11
+ export const withoutQuery = (href?: string): string =>
12
+ (href || '').replace(/\?.*/, '').replace(/\/$/, '');
12
13
 
13
- export const getOrigin = (href?: string) => (isURL(href) ? new URL(href).origin : undefined);
14
- export const getPathname = (href?: string) => (isURL(href) ? new URL(href).pathname : undefined);
15
- export const getHash = (href?: string) => (isURL(href) ? new URL(href).hash : undefined);
14
+ export const joinPath = (...path: string[]): string =>
15
+ path.filter(Boolean).join('/').replace(/\/+/g, '/');
@@ -1,2 +0,0 @@
1
- import type { LinkProps } from '../../model/LinkProps';
2
- export declare const mergeTopItems: <L extends LinkProps>(left?: L[] | undefined, right?: L[] | undefined) => L[];
@@ -1,2 +0,0 @@
1
- import type { LinkProps } from '../../model/LinkProps';
2
- export declare const mergeTopItems: <L extends LinkProps>(left?: L[] | undefined, right?: L[] | undefined) => L[];
@@ -1,8 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.mergeTopItems = void 0;
3
- const cmp = (a) => (b) => a?.href === b?.href;
4
- const substitute = (items, substitution) => (items || []).map((_) => substitution?.find(cmp(_)) || _);
5
- const subtract = (minuend, subtrahend) => (minuend || []).filter((_) => !subtrahend?.find(cmp(_)));
6
- const mergeTopItems = (left, right) => substitute(left, right).concat(subtract(right, left));
7
- exports.mergeTopItems = mergeTopItems;
8
- //# sourceMappingURL=mergeTopItems.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mergeTopItems.js","sourceRoot":"","sources":["../../../src/services/sitemap/mergeTopItems.ts"],"names":[],"mappings":";;AAEA,MAAM,GAAG,GAAG,CAAC,CAAa,EAAE,EAAE,CAAC,CAAC,CAAa,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,CAAC,EAAE,IAAI,CAAC;AAEtE,MAAM,UAAU,GAAG,CAAsB,KAAW,EAAE,YAAkB,EAAO,EAAE,CAC/E,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAE5D,MAAM,QAAQ,GAAG,CAAsB,OAAa,EAAE,UAAgB,EAAO,EAAE,CAC7E,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEpD,MAAM,aAAa,GAAG,CAAsB,IAAU,EAAE,KAAW,EAAO,EAAE,CACjF,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;AAD3C,QAAA,aAAa,iBAC8B"}
@@ -1,2 +0,0 @@
1
- import type { LinkProps } from '../../model/LinkProps';
2
- export declare const mergeTopItems: <L extends LinkProps>(left?: L[] | undefined, right?: L[] | undefined) => L[];
@@ -1,5 +0,0 @@
1
- const cmp = (a) => (b) => a?.href === b?.href;
2
- const substitute = (items, substitution) => (items || []).map((_) => substitution?.find(cmp(_)) || _);
3
- const subtract = (minuend, subtrahend) => (minuend || []).filter((_) => !subtrahend?.find(cmp(_)));
4
- export const mergeTopItems = (left, right) => substitute(left, right).concat(subtract(right, left));
5
- //# sourceMappingURL=mergeTopItems.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mergeTopItems.js","sourceRoot":"","sources":["../../../src/services/sitemap/mergeTopItems.ts"],"names":[],"mappings":"AAEA,MAAM,GAAG,GAAG,CAAC,CAAa,EAAE,EAAE,CAAC,CAAC,CAAa,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,CAAC,EAAE,IAAI,CAAC;AAEtE,MAAM,UAAU,GAAG,CAAsB,KAAW,EAAE,YAAkB,EAAO,EAAE,CAC/E,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAE5D,MAAM,QAAQ,GAAG,CAAsB,OAAa,EAAE,UAAgB,EAAO,EAAE,CAC7E,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3D,MAAM,CAAC,MAAM,aAAa,GAAG,CAAsB,IAAU,EAAE,KAAW,EAAO,EAAE,CACjF,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- import type { LinkProps } from '../../model/LinkProps';
2
- export declare const mergeTopItems: <L extends LinkProps>(left?: L[] | undefined, right?: L[] | undefined) => L[];
@@ -1,2 +0,0 @@
1
- import type { LinkProps } from '../../model/LinkProps';
2
- export declare const mergeTopItems: <L extends LinkProps>(left?: L[] | undefined, right?: L[] | undefined) => L[];
@@ -1,8 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.mergeTopItems = void 0;
3
- const cmp = (a) => (b) => a?.href === b?.href;
4
- const substitute = (items, substitution) => (items || []).map((_) => substitution?.find(cmp(_)) || _);
5
- const subtract = (minuend, subtrahend) => (minuend || []).filter((_) => !subtrahend?.find(cmp(_)));
6
- const mergeTopItems = (left, right) => substitute(left, right).concat(subtract(right, left));
7
- exports.mergeTopItems = mergeTopItems;
8
- //# sourceMappingURL=mergeTopItems.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mergeTopItems.js","sourceRoot":"","sources":["../../../src/services/sitemap/mergeTopItems.ts"],"names":[],"mappings":";;AAEA,MAAM,GAAG,GAAG,CAAC,CAAa,EAAE,EAAE,CAAC,CAAC,CAAa,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,CAAC,EAAE,IAAI,CAAC;AAEtE,MAAM,UAAU,GAAG,CAAsB,KAAW,EAAE,YAAkB,EAAO,EAAE,CAC/E,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAE5D,MAAM,QAAQ,GAAG,CAAsB,OAAa,EAAE,UAAgB,EAAO,EAAE,CAC7E,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEpD,MAAM,aAAa,GAAG,CAAsB,IAAU,EAAE,KAAW,EAAO,EAAE,CACjF,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;AAD3C,QAAA,aAAa,iBAC8B"}
@@ -1,2 +0,0 @@
1
- import type { LinkProps } from '../../model/LinkProps';
2
- export declare const mergeTopItems: <L extends LinkProps>(left?: L[] | undefined, right?: L[] | undefined) => L[];
@@ -1,5 +0,0 @@
1
- const cmp = (a) => (b) => a?.href === b?.href;
2
- const substitute = (items, substitution) => (items || []).map((_) => substitution?.find(cmp(_)) || _);
3
- const subtract = (minuend, subtrahend) => (minuend || []).filter((_) => !subtrahend?.find(cmp(_)));
4
- export const mergeTopItems = (left, right) => substitute(left, right).concat(subtract(right, left));
5
- //# sourceMappingURL=mergeTopItems.js.map