@websolutespa/bom-mixer-hooks 1.9.2 → 1.9.4
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/CHANGELOG.md +20 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +14 -3
- package/dist/index.mjs +14 -3
- package/package.json +1 -1
- package/src/useLayout/useLayout.tsx +10 -3
- package/src/useMetaData/useMetaData.tsx +13 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @websolutespa/bom-mixer-hooks
|
|
2
2
|
|
|
3
|
+
## 1.9.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Added: IApp global
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @websolutespa/bom-mixer-models@1.10.3
|
|
10
|
+
- @websolutespa/bom-mixer-store@1.10.1
|
|
11
|
+
- @websolutespa/bom-core@1.8.24
|
|
12
|
+
|
|
13
|
+
## 1.9.3
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 0c7f05f: Modified: useMetaData canonical
|
|
18
|
+
- Updated dependencies [0c7f05f]
|
|
19
|
+
- Updated dependencies [0c7f05f]
|
|
20
|
+
- @websolutespa/bom-mixer-models@1.10.1
|
|
21
|
+
- @websolutespa/bom-core@1.8.23
|
|
22
|
+
|
|
3
23
|
## 1.9.2
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as react from 'react';
|
|
|
2
2
|
import react__default, { RefObject, Dispatch, SetStateAction, CSSProperties, MutableRefObject, ComponentProps, useEffect } from 'react';
|
|
3
3
|
import { ApiRequestOptions } from '@websolutespa/bom-mixer-store';
|
|
4
4
|
import * as _websolutespa_bom_core from '@websolutespa/bom-core';
|
|
5
|
-
import { QueryParams, IEquatable, IFeatureType, ILabel, ILocalizable, ILayout, ILocalized, IPage } from '@websolutespa/bom-core';
|
|
5
|
+
import { QueryParams, IEquatable, IFeatureType, ILabel, ILocalizable, ILayout, IAppExtended, ILocalized, IPage } from '@websolutespa/bom-core';
|
|
6
6
|
import * as zustand from 'zustand';
|
|
7
7
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
8
8
|
import { ILazyModules, IMetaData, StructuredDataType, OpenGraphType, TwitterCardType } from '@websolutespa/bom-mixer-models';
|
|
@@ -392,11 +392,12 @@ declare function parseLabel(dictionary: Record<string, ILocalizable | undefined>
|
|
|
392
392
|
declare function parseParams(label: string, params: Record<string, any>): string;
|
|
393
393
|
|
|
394
394
|
type ILayoutContext = ILayout;
|
|
395
|
-
declare const useLayout: () => ILayout;
|
|
396
395
|
declare function LayoutProvider({ children, layout }: {
|
|
397
396
|
children?: react__default.ReactNode;
|
|
398
397
|
layout: ILayout;
|
|
399
398
|
}): react_jsx_runtime.JSX.Element;
|
|
399
|
+
type UseLayout = <T extends IAppExtended = IAppExtended>() => ILayout<T>;
|
|
400
|
+
declare const useLayout: UseLayout;
|
|
400
401
|
|
|
401
402
|
type ILazyModulesContext = ILazyModules;
|
|
402
403
|
declare const useLazyModules: () => ILazyModules;
|
package/dist/index.js
CHANGED
|
@@ -248,10 +248,11 @@ var createGenericContext = (defaultContext = null) => {
|
|
|
248
248
|
|
|
249
249
|
// src/useLayout/useLayout.tsx
|
|
250
250
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
251
|
-
var [
|
|
251
|
+
var [useLayout_, LayoutContextProvider] = createGenericContext();
|
|
252
252
|
function LayoutProvider({ children, layout }) {
|
|
253
253
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LayoutContextProvider, { value: layout, children });
|
|
254
254
|
}
|
|
255
|
+
var useLayout = useLayout_;
|
|
255
256
|
|
|
256
257
|
// src/useApi/useApi.ts
|
|
257
258
|
function useApiFetch(pathname, options = {}) {
|
|
@@ -1536,9 +1537,13 @@ function MetaDataProvider({ children, metaData }) {
|
|
|
1536
1537
|
const description = (0, import_html_to_text.convert)(((_b = page.meta) == null ? void 0 : _b.description) || page.abstract || "");
|
|
1537
1538
|
const media = ((_c = page.meta) == null ? void 0 : _c.image) || page.media;
|
|
1538
1539
|
const image = media ? (0, import_bom_mixer_models.resolveHref)(media.src || media.url) : brand.logo;
|
|
1539
|
-
|
|
1540
|
+
let canonical = (0, import_bom_mixer_models.resolveHref)(page.href);
|
|
1540
1541
|
const queryIndex = router.asPath.indexOf("?");
|
|
1541
|
-
const
|
|
1542
|
+
const query = queryIndex !== -1 ? router.asPath.substring(queryIndex) : "";
|
|
1543
|
+
if (query.match(/^\?pagination\[page\]=(\d+)$/) && query !== "?pagination[page]=1") {
|
|
1544
|
+
canonical = `${canonical}${query}`;
|
|
1545
|
+
}
|
|
1546
|
+
const url = `${canonical}${query}`;
|
|
1542
1547
|
const alternates = (0, import_react26.useMemo)(() => {
|
|
1543
1548
|
const alternates2 = [];
|
|
1544
1549
|
page.alternates.forEach((alternate) => {
|
|
@@ -1615,6 +1620,12 @@ function MetaDataProvider({ children, metaData }) {
|
|
|
1615
1620
|
},
|
|
1616
1621
|
url: brand.url
|
|
1617
1622
|
/*
|
|
1623
|
+
description,
|
|
1624
|
+
founder,
|
|
1625
|
+
foundingDate,
|
|
1626
|
+
numberOfEmployees,
|
|
1627
|
+
*/
|
|
1628
|
+
/*
|
|
1618
1629
|
foundingDate: '2020-01-01',
|
|
1619
1630
|
numberOfEmployees: {
|
|
1620
1631
|
'@type': 'QuantitativeValue',
|
package/dist/index.mjs
CHANGED
|
@@ -93,10 +93,11 @@ var createGenericContext = (defaultContext = null) => {
|
|
|
93
93
|
|
|
94
94
|
// src/useLayout/useLayout.tsx
|
|
95
95
|
import { jsx } from "react/jsx-runtime";
|
|
96
|
-
var [
|
|
96
|
+
var [useLayout_, LayoutContextProvider] = createGenericContext();
|
|
97
97
|
function LayoutProvider({ children, layout }) {
|
|
98
98
|
return /* @__PURE__ */ jsx(LayoutContextProvider, { value: layout, children });
|
|
99
99
|
}
|
|
100
|
+
var useLayout = useLayout_;
|
|
100
101
|
|
|
101
102
|
// src/useApi/useApi.ts
|
|
102
103
|
function useApiFetch(pathname, options = {}) {
|
|
@@ -1381,9 +1382,13 @@ function MetaDataProvider({ children, metaData }) {
|
|
|
1381
1382
|
const description = htmlToText(((_b = page.meta) == null ? void 0 : _b.description) || page.abstract || "");
|
|
1382
1383
|
const media = ((_c = page.meta) == null ? void 0 : _c.image) || page.media;
|
|
1383
1384
|
const image = media ? resolveHref(media.src || media.url) : brand.logo;
|
|
1384
|
-
|
|
1385
|
+
let canonical = resolveHref(page.href);
|
|
1385
1386
|
const queryIndex = router.asPath.indexOf("?");
|
|
1386
|
-
const
|
|
1387
|
+
const query = queryIndex !== -1 ? router.asPath.substring(queryIndex) : "";
|
|
1388
|
+
if (query.match(/^\?pagination\[page\]=(\d+)$/) && query !== "?pagination[page]=1") {
|
|
1389
|
+
canonical = `${canonical}${query}`;
|
|
1390
|
+
}
|
|
1391
|
+
const url = `${canonical}${query}`;
|
|
1387
1392
|
const alternates = useMemo5(() => {
|
|
1388
1393
|
const alternates2 = [];
|
|
1389
1394
|
page.alternates.forEach((alternate) => {
|
|
@@ -1460,6 +1465,12 @@ function MetaDataProvider({ children, metaData }) {
|
|
|
1460
1465
|
},
|
|
1461
1466
|
url: brand.url
|
|
1462
1467
|
/*
|
|
1468
|
+
description,
|
|
1469
|
+
founder,
|
|
1470
|
+
foundingDate,
|
|
1471
|
+
numberOfEmployees,
|
|
1472
|
+
*/
|
|
1473
|
+
/*
|
|
1463
1474
|
foundingDate: '2020-01-01',
|
|
1464
1475
|
numberOfEmployees: {
|
|
1465
1476
|
'@type': 'QuantitativeValue',
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ILayout } from '@websolutespa/bom-core';
|
|
1
|
+
import { IAppExtended, ILayout } from '@websolutespa/bom-core';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { createGenericContext } from '../useGenericContext/useGenericContext';
|
|
4
4
|
|
|
5
5
|
export type ILayoutContext = ILayout;
|
|
6
6
|
|
|
7
|
-
const [
|
|
7
|
+
const [useLayout_, LayoutContextProvider] = createGenericContext<ILayoutContext>();
|
|
8
8
|
|
|
9
9
|
function LayoutProvider({ children, layout }: { children?: React.ReactNode, layout: ILayout }) {
|
|
10
10
|
// console.log('LayoutProvider.context', context);
|
|
@@ -15,5 +15,12 @@ function LayoutProvider({ children, layout }: { children?: React.ReactNode, layo
|
|
|
15
15
|
);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
type UseLayout = <T extends IAppExtended = IAppExtended>() => ILayout<T>;
|
|
19
|
+
|
|
20
|
+
const useLayout:UseLayout = useLayout_ as UseLayout;
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
LayoutProvider,
|
|
24
|
+
useLayout
|
|
25
|
+
};
|
|
19
26
|
|
|
@@ -48,9 +48,14 @@ function MetaDataProvider({ children, metaData }: {
|
|
|
48
48
|
const description = htmlToText(page.meta?.description || page.abstract || '');
|
|
49
49
|
const media = ((page.meta as { image: IMedia } | undefined)?.image || page.media);
|
|
50
50
|
const image = media ? resolveHref(media.src || media.url) : brand.logo;
|
|
51
|
-
|
|
51
|
+
let canonical = resolveHref(page.href);
|
|
52
52
|
const queryIndex = router.asPath.indexOf('?');
|
|
53
|
-
const
|
|
53
|
+
const query = queryIndex !== -1 ? router.asPath.substring(queryIndex) : '';
|
|
54
|
+
if (query.match(/^\?pagination\[page\]=(\d+)$/) && query !== '?pagination[page]=1') {
|
|
55
|
+
canonical = `${canonical}${query}`;
|
|
56
|
+
// title = `${title} - ${query.replace('?pagination[page]=','')}`;
|
|
57
|
+
}
|
|
58
|
+
const url = `${canonical}${query}`;
|
|
54
59
|
const alternates = useMemo(() => {
|
|
55
60
|
const alternates: IAlternate[] = [];
|
|
56
61
|
page.alternates.forEach((alternate: IRoute) => {
|
|
@@ -127,6 +132,12 @@ function MetaDataProvider({ children, metaData }: {
|
|
|
127
132
|
},
|
|
128
133
|
url: brand.url,
|
|
129
134
|
/*
|
|
135
|
+
description,
|
|
136
|
+
founder,
|
|
137
|
+
foundingDate,
|
|
138
|
+
numberOfEmployees,
|
|
139
|
+
*/
|
|
140
|
+
/*
|
|
130
141
|
foundingDate: '2020-01-01',
|
|
131
142
|
numberOfEmployees: {
|
|
132
143
|
'@type': 'QuantitativeValue',
|