@sentecacommerce-theme/lib 0.12.86-alpha.6 → 0.12.88
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/dist/cjs/listing/components/BasicListingSEO.js +6 -4
- package/dist/cjs/seo/components/BasicSEO/index.js +17 -2
- package/dist/esm/listing/components/BasicListingSEO.js +7 -5
- package/dist/esm/seo/components/BasicSEO/index.js +17 -2
- package/dist/types/listing/components/BasicListingSEO.d.ts +3 -1
- package/package.json +5 -5
@@ -12,15 +12,17 @@ function _interopRequireDefault(obj) {
|
|
12
12
|
};
|
13
13
|
}
|
14
14
|
var BasicListingSEO = function(param) {
|
15
|
-
var _favorTitleTemplateOverMeta = param.favorTitleTemplateOverMeta, favorTitleTemplateOverMeta = _favorTitleTemplateOverMeta === void 0 ? false : _favorTitleTemplateOverMeta, _favorDescriptionTemplateOverMeta = param.favorDescriptionTemplateOverMeta, favorDescriptionTemplateOverMeta = _favorDescriptionTemplateOverMeta === void 0 ? false : _favorDescriptionTemplateOverMeta, _titleTemplate = param.titleTemplate, titleTemplate = _titleTemplate === void 0 ? ':title:' : _titleTemplate, _descriptionTemplate = param.descriptionTemplate, descriptionTemplate = _descriptionTemplate === void 0 ? ':description:' : _descriptionTemplate;
|
16
|
-
var
|
15
|
+
var _favorTitleTemplateOverMeta = param.favorTitleTemplateOverMeta, favorTitleTemplateOverMeta = _favorTitleTemplateOverMeta === void 0 ? false : _favorTitleTemplateOverMeta, _favorDescriptionTemplateOverMeta = param.favorDescriptionTemplateOverMeta, favorDescriptionTemplateOverMeta = _favorDescriptionTemplateOverMeta === void 0 ? false : _favorDescriptionTemplateOverMeta, _titleTemplate = param.titleTemplate, titleTemplate = _titleTemplate === void 0 ? ':title:' : _titleTemplate, _descriptionTemplate = param.descriptionTemplate, descriptionTemplate = _descriptionTemplate === void 0 ? ':description:' : _descriptionTemplate, _pageTemplate = param.pageTemplate, pageTemplate = _pageTemplate === void 0 ? ':page' : _pageTemplate;
|
16
|
+
var ref7, ref1, ref2, ref3, ref4, ref5;
|
17
17
|
var ref6 = (0, _hooks).useListingMeta(), displayName = ref6.displayName, metaTitle = ref6.metaTitle, metaKeywords = ref6.metaKeywords, metaDescription = ref6.metaDescription, getAssetByKey = ref6.getAssetByKey;
|
18
|
-
var image = (
|
18
|
+
var image = (ref7 = getAssetByKey('image')) === null || ref7 === void 0 ? void 0 : (ref1 = ref7.sources) === null || ref1 === void 0 ? void 0 : (ref2 = ref1[0]) === null || ref2 === void 0 ? void 0 : ref2.url;
|
19
19
|
var topBanner = (ref3 = getAssetByKey('top-banner')) === null || ref3 === void 0 ? void 0 : (ref4 = ref3.sources) === null || ref4 === void 0 ? void 0 : (ref5 = ref4[0]) === null || ref5 === void 0 ? void 0 : ref5.url;
|
20
20
|
var imagesConfig = (0, _useConfig).useConfigState().imagesConfig;
|
21
|
+
var pagination = (0, _hooks).useListingPagination().pagination;
|
21
22
|
var createTemplate = function(template) {
|
23
|
+
var ref;
|
22
24
|
if (!template) return '';
|
23
|
-
return template.replace(':title:', metaTitle || displayName).replace(':name:', displayName).replace(':description:', metaDescription);
|
25
|
+
return template.replace(':title:', metaTitle || displayName).replace(':name:', displayName).replace(':description:', metaDescription).replace(':page', Boolean(((ref = pagination) === null || ref === void 0 ? void 0 : ref.currentPage) - 1) ? "".concat(pagination === null || pagination === void 0 ? void 0 : pagination.currentPage) : '');
|
24
26
|
};
|
25
27
|
var formattedTitle = favorTitleTemplateOverMeta ? createTemplate(titleTemplate) : metaTitle || createTemplate(titleTemplate);
|
26
28
|
var formattedDescription = favorDescriptionTemplateOverMeta ? createTemplate(descriptionTemplate) : metaDescription || createTemplate(descriptionTemplate);
|
@@ -4,17 +4,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
exports.BasicSEO = BasicSEO;
|
5
5
|
var _react = _interopRequireDefault(require("react"));
|
6
6
|
var _head = _interopRequireDefault(require("next/head"));
|
7
|
+
var _router = require("next/router");
|
8
|
+
var _index = require("../../../index");
|
9
|
+
var _listing = require("../../../listing");
|
7
10
|
function _interopRequireDefault(obj) {
|
8
11
|
return obj && obj.__esModule ? obj : {
|
9
12
|
default: obj
|
10
13
|
};
|
11
14
|
}
|
12
15
|
function BasicSEO(props) {
|
16
|
+
var ref;
|
13
17
|
var title = props.title, description = props.description, keywords = props.keywords, noIndex = props.noIndex;
|
14
|
-
|
18
|
+
var domain = (0, _index).useConfigState().domain;
|
19
|
+
var pagination = (0, _listing).useListingPagination().pagination;
|
20
|
+
var router = (0, _router).useRouter();
|
21
|
+
var url = "https://".concat(domain).concat(router === null || router === void 0 ? void 0 : (ref = router.asPath) === null || ref === void 0 ? void 0 : ref.split('?')[0]);
|
22
|
+
var isSearchPage = router.asPath.includes('/search?q=');
|
23
|
+
return(/*#__PURE__*/ _react.default.createElement(_head.default, null, (Boolean(noIndex) || isSearchPage) && /*#__PURE__*/ _react.default.createElement("meta", {
|
15
24
|
name: "robots",
|
16
25
|
content: "noindex"
|
17
|
-
}), Boolean(title) && /*#__PURE__*/ _react.default.createElement("title", null, title),
|
26
|
+
}), Boolean(title) && /*#__PURE__*/ _react.default.createElement("title", null, title), (pagination === null || pagination === void 0 ? void 0 : pagination.hasPrevious) && /*#__PURE__*/ _react.default.createElement("link", {
|
27
|
+
rel: "prev",
|
28
|
+
href: "".concat(url, "?page=").concat(pagination.previousQuery.page)
|
29
|
+
}), (pagination === null || pagination === void 0 ? void 0 : pagination.hasNext) && /*#__PURE__*/ _react.default.createElement("link", {
|
30
|
+
rel: "next",
|
31
|
+
href: "".concat(url, "?page=").concat(pagination.nextQuery.page)
|
32
|
+
}), Boolean(description) && /*#__PURE__*/ _react.default.createElement("meta", {
|
18
33
|
name: "description",
|
19
34
|
content: description
|
20
35
|
}), Boolean(keywords) && /*#__PURE__*/ _react.default.createElement("meta", {
|
@@ -1,22 +1,24 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { useConfigState } from '../../hooks/useConfig';
|
3
3
|
import { BasicSEO, OpenGraph } from '../../seo';
|
4
|
-
import { useListingMeta } from '../hooks';
|
4
|
+
import { useListingMeta, useListingPagination } from '../hooks';
|
5
5
|
/**
|
6
6
|
* Template Options:
|
7
7
|
* :title: -> is going to be replace with the title
|
8
8
|
* :description: -> is going to be replace with the description
|
9
9
|
* :name: -> is going to be replace with the name
|
10
10
|
*/ export var BasicListingSEO = function(param) {
|
11
|
-
var _favorTitleTemplateOverMeta = param.favorTitleTemplateOverMeta, favorTitleTemplateOverMeta = _favorTitleTemplateOverMeta === void 0 ? false : _favorTitleTemplateOverMeta, _favorDescriptionTemplateOverMeta = param.favorDescriptionTemplateOverMeta, favorDescriptionTemplateOverMeta = _favorDescriptionTemplateOverMeta === void 0 ? false : _favorDescriptionTemplateOverMeta, _titleTemplate = param.titleTemplate, titleTemplate = _titleTemplate === void 0 ? ':title:' : _titleTemplate, _descriptionTemplate = param.descriptionTemplate, descriptionTemplate = _descriptionTemplate === void 0 ? ':description:' : _descriptionTemplate;
|
12
|
-
var
|
11
|
+
var _favorTitleTemplateOverMeta = param.favorTitleTemplateOverMeta, favorTitleTemplateOverMeta = _favorTitleTemplateOverMeta === void 0 ? false : _favorTitleTemplateOverMeta, _favorDescriptionTemplateOverMeta = param.favorDescriptionTemplateOverMeta, favorDescriptionTemplateOverMeta = _favorDescriptionTemplateOverMeta === void 0 ? false : _favorDescriptionTemplateOverMeta, _titleTemplate = param.titleTemplate, titleTemplate = _titleTemplate === void 0 ? ':title:' : _titleTemplate, _descriptionTemplate = param.descriptionTemplate, descriptionTemplate = _descriptionTemplate === void 0 ? ':description:' : _descriptionTemplate, _pageTemplate = param.pageTemplate, pageTemplate = _pageTemplate === void 0 ? ':page' : _pageTemplate;
|
12
|
+
var ref7, ref1, ref2, ref3, ref4, ref5;
|
13
13
|
var ref6 = useListingMeta(), displayName = ref6.displayName, metaTitle = ref6.metaTitle, metaKeywords = ref6.metaKeywords, metaDescription = ref6.metaDescription, getAssetByKey = ref6.getAssetByKey;
|
14
|
-
var image = (
|
14
|
+
var image = (ref7 = getAssetByKey('image')) === null || ref7 === void 0 ? void 0 : (ref1 = ref7.sources) === null || ref1 === void 0 ? void 0 : (ref2 = ref1[0]) === null || ref2 === void 0 ? void 0 : ref2.url;
|
15
15
|
var topBanner = (ref3 = getAssetByKey('top-banner')) === null || ref3 === void 0 ? void 0 : (ref4 = ref3.sources) === null || ref4 === void 0 ? void 0 : (ref5 = ref4[0]) === null || ref5 === void 0 ? void 0 : ref5.url;
|
16
16
|
var imagesConfig = useConfigState().imagesConfig;
|
17
|
+
var pagination = useListingPagination().pagination;
|
17
18
|
var createTemplate = function(template) {
|
19
|
+
var ref;
|
18
20
|
if (!template) return '';
|
19
|
-
return template.replace(':title:', metaTitle || displayName).replace(':name:', displayName).replace(':description:', metaDescription);
|
21
|
+
return template.replace(':title:', metaTitle || displayName).replace(':name:', displayName).replace(':description:', metaDescription).replace(':page', Boolean(((ref = pagination) === null || ref === void 0 ? void 0 : ref.currentPage) - 1) ? "".concat(pagination === null || pagination === void 0 ? void 0 : pagination.currentPage) : '');
|
20
22
|
};
|
21
23
|
var formattedTitle = favorTitleTemplateOverMeta ? createTemplate(titleTemplate) : metaTitle || createTemplate(titleTemplate);
|
22
24
|
var formattedDescription = favorDescriptionTemplateOverMeta ? createTemplate(descriptionTemplate) : metaDescription || createTemplate(descriptionTemplate);
|
@@ -1,11 +1,26 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import Head from 'next/head';
|
3
|
+
import { useRouter } from 'next/router';
|
4
|
+
import { useConfigState } from '../../../index';
|
5
|
+
import { useListingPagination } from '../../../listing';
|
3
6
|
export function BasicSEO(props) {
|
7
|
+
var ref;
|
4
8
|
var title = props.title, description = props.description, keywords = props.keywords, noIndex = props.noIndex;
|
5
|
-
|
9
|
+
var domain = useConfigState().domain;
|
10
|
+
var pagination = useListingPagination().pagination;
|
11
|
+
var router = useRouter();
|
12
|
+
var url = "https://".concat(domain).concat(router === null || router === void 0 ? void 0 : (ref = router.asPath) === null || ref === void 0 ? void 0 : ref.split('?')[0]);
|
13
|
+
var isSearchPage = router.asPath.includes('/search?q=');
|
14
|
+
return(/*#__PURE__*/ React.createElement(Head, null, (Boolean(noIndex) || isSearchPage) && /*#__PURE__*/ React.createElement("meta", {
|
6
15
|
name: "robots",
|
7
16
|
content: "noindex"
|
8
|
-
}), Boolean(title) && /*#__PURE__*/ React.createElement("title", null, title),
|
17
|
+
}), Boolean(title) && /*#__PURE__*/ React.createElement("title", null, title), (pagination === null || pagination === void 0 ? void 0 : pagination.hasPrevious) && /*#__PURE__*/ React.createElement("link", {
|
18
|
+
rel: "prev",
|
19
|
+
href: "".concat(url, "?page=").concat(pagination.previousQuery.page)
|
20
|
+
}), (pagination === null || pagination === void 0 ? void 0 : pagination.hasNext) && /*#__PURE__*/ React.createElement("link", {
|
21
|
+
rel: "next",
|
22
|
+
href: "".concat(url, "?page=").concat(pagination.nextQuery.page)
|
23
|
+
}), Boolean(description) && /*#__PURE__*/ React.createElement("meta", {
|
9
24
|
name: "description",
|
10
25
|
content: description
|
11
26
|
}), Boolean(keywords) && /*#__PURE__*/ React.createElement("meta", {
|
@@ -3,6 +3,8 @@ export declare type BasicListingSEOProps = {
|
|
3
3
|
favorDescriptionTemplateOverMeta?: boolean;
|
4
4
|
titleTemplate?: string;
|
5
5
|
descriptionTemplate?: string;
|
6
|
+
pageTemplate?: string;
|
7
|
+
currentPageTemplate?: string;
|
6
8
|
};
|
7
9
|
/**
|
8
10
|
* Template Options:
|
@@ -10,4 +12,4 @@ export declare type BasicListingSEOProps = {
|
|
10
12
|
* :description: -> is going to be replace with the description
|
11
13
|
* :name: -> is going to be replace with the name
|
12
14
|
*/
|
13
|
-
export declare const BasicListingSEO: ({ favorTitleTemplateOverMeta, favorDescriptionTemplateOverMeta, titleTemplate, descriptionTemplate, }: BasicListingSEOProps) => JSX.Element;
|
15
|
+
export declare const BasicListingSEO: ({ favorTitleTemplateOverMeta, favorDescriptionTemplateOverMeta, titleTemplate, descriptionTemplate, pageTemplate, }: BasicListingSEOProps) => JSX.Element;
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sentecacommerce-theme/lib",
|
3
3
|
"sideEffects": false,
|
4
|
-
"version": "0.12.
|
4
|
+
"version": "0.12.88",
|
5
5
|
"main": "dist/cjs/index.js",
|
6
6
|
"module": "dist/esm/index.js",
|
7
7
|
"types": "dist/types/index.d.ts",
|
@@ -31,19 +31,19 @@
|
|
31
31
|
"watch:cjs": "swc src --out-dir dist/cjs -w",
|
32
32
|
"watch:esm": "swc src --out-dir dist/esm --no-swcrc -w"
|
33
33
|
},
|
34
|
-
"gitHead": "
|
34
|
+
"gitHead": "bc6a250aef8a245926336a983c75c63bc6a731be",
|
35
35
|
"peerDependencies": {
|
36
36
|
"react-query": "^2.26.2"
|
37
37
|
},
|
38
38
|
"dependencies": {
|
39
|
-
"@sentecacommerce-theme/base": "^0.12.
|
40
|
-
"@sentecacommerce-theme/cms": "^0.12.
|
39
|
+
"@sentecacommerce-theme/base": "^0.12.88",
|
40
|
+
"@sentecacommerce-theme/cms": "^0.12.88",
|
41
41
|
"@sentecacommerce/sdk": "2.0.161",
|
42
42
|
"body-scroll-lock": "^3.1.5",
|
43
43
|
"copy-to-clipboard": "^3.3.1",
|
44
44
|
"embla-carousel": "^4.5.1",
|
45
45
|
"js-cookie": "^3.0.1",
|
46
|
-
"next": "
|
46
|
+
"next": "10.2.3",
|
47
47
|
"node-fetch": "^2.6.1",
|
48
48
|
"react-query": "^2.26.2",
|
49
49
|
"styled-components": "^5.2.1",
|