@mindful-web/marko-web-search 1.59.2 → 1.68.0
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/components/build-href.marko.js +2 -2
- package/components/filters/content-types.marko.js +2 -2
- package/components/filters/filter-block.marko.js +2 -2
- package/components/filters/filter-container.marko.js +2 -2
- package/components/filters/selected/index.marko.js +2 -2
- package/components/filters/selected/item.marko.js +2 -2
- package/components/filters/website-sections-by-alias.marko.js +2 -2
- package/components/filters/website-sections.marko.js +2 -2
- package/components/form/index.marko +2 -4
- package/components/form/index.marko.js +4 -6
- package/components/form/input.marko.js +2 -2
- package/components/links/link.marko.js +2 -2
- package/components/links/next-page.marko +4 -9
- package/components/links/next-page.marko.js +6 -11
- package/components/links/previous-page.marko +4 -9
- package/components/links/previous-page.marko.js +6 -11
- package/components/links/reset-filter.marko +2 -4
- package/components/links/reset-filter.marko.js +4 -6
- package/components/links/set-filter-value.marko +2 -4
- package/components/links/set-filter-value.marko.js +4 -6
- package/components/pagination-controls.marko +3 -20
- package/components/pagination-controls.marko.js +10 -34
- package/components/query-child-sections.marko.js +2 -2
- package/components/query.marko +6 -18
- package/components/query.marko.js +8 -18
- package/components/sort-by/index.marko.js +2 -2
- package/config/index.js +3 -6
- package/index.js +3 -3
- package/package.json +2 -2
- package/loaders/search.js +0 -108
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.68.0/components/build-href.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
module_defaultValue = require("@mindful-web/marko-core/utils/default-value"),
|
|
8
8
|
defaultValue = module_defaultValue.default || module_defaultValue,
|
|
@@ -42,5 +42,5 @@ marko_template._ = marko_renderer(render, {
|
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
marko_template.meta = {
|
|
45
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
45
|
+
id: "/@mindful-web/marko-web-search$1.68.0/components/build-href.marko"
|
|
46
46
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.68.0/components/filters/content-types.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
module_defaultValue = require("@mindful-web/marko-core/utils/default-value"),
|
|
8
8
|
defaultValue = module_defaultValue.default || module_defaultValue,
|
|
@@ -35,7 +35,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
marko_template.meta = {
|
|
38
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
38
|
+
id: "/@mindful-web/marko-web-search$1.68.0/components/filters/content-types.marko",
|
|
39
39
|
tags: [
|
|
40
40
|
"./filter-block.marko"
|
|
41
41
|
]
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.68.0/components/filters/filter-block.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
module_objectPath_module = require("@mindful-web/object-path"),
|
|
8
8
|
objectPath_module = module_objectPath_module.default || module_objectPath_module,
|
|
@@ -141,7 +141,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
141
141
|
});
|
|
142
142
|
|
|
143
143
|
marko_template.meta = {
|
|
144
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
144
|
+
id: "/@mindful-web/marko-web-search$1.68.0/components/filters/filter-block.marko",
|
|
145
145
|
tags: [
|
|
146
146
|
"@mindful-web/marko-web/components/browser-component.marko",
|
|
147
147
|
"../links/set-filter-value.marko",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.68.0/components/filters/filter-container.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
module_objectPath_module = require("@mindful-web/object-path"),
|
|
8
8
|
objectPath_module = module_objectPath_module.default || module_objectPath_module,
|
|
@@ -76,7 +76,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
marko_template.meta = {
|
|
79
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
79
|
+
id: "/@mindful-web/marko-web-search$1.68.0/components/filters/filter-container.marko",
|
|
80
80
|
tags: [
|
|
81
81
|
"@mindful-web/marko-web/components/browser-component.marko",
|
|
82
82
|
"@mindful-web/marko-web/components/element/index.marko",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.68.0/components/filters/selected/index.marko",
|
|
6
6
|
marko_component = require("./index.marko"),
|
|
7
7
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
8
8
|
module_defaultValue = require("@mindful-web/marko-core/utils/default-value"),
|
|
@@ -105,7 +105,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
105
105
|
}, marko_component);
|
|
106
106
|
|
|
107
107
|
marko_template.meta = {
|
|
108
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
108
|
+
id: "/@mindful-web/marko-web-search$1.68.0/components/filters/selected/index.marko",
|
|
109
109
|
component: "./index.marko",
|
|
110
110
|
tags: [
|
|
111
111
|
"./item.marko",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.68.0/components/filters/selected/item.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
module_objectPath_module = require("@mindful-web/object-path"),
|
|
8
8
|
objectPath_module = module_objectPath_module.default || module_objectPath_module,
|
|
@@ -91,7 +91,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
marko_template.meta = {
|
|
94
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
94
|
+
id: "/@mindful-web/marko-web-search$1.68.0/components/filters/selected/item.marko",
|
|
95
95
|
tags: [
|
|
96
96
|
"@mindful-web/marko-web/components/element/index.marko",
|
|
97
97
|
"@mindful-web/marko-web-icons/components/icon.marko",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.68.0/components/filters/website-sections-by-alias.marko",
|
|
6
6
|
marko_component = require("./website-sections-by-alias.marko"),
|
|
7
7
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
8
8
|
module_defaultValue = require("@mindful-web/marko-core/utils/default-value"),
|
|
@@ -130,7 +130,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
130
130
|
}, marko_component);
|
|
131
131
|
|
|
132
132
|
marko_template.meta = {
|
|
133
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
133
|
+
id: "/@mindful-web/marko-web-search$1.68.0/components/filters/website-sections-by-alias.marko",
|
|
134
134
|
component: "./website-sections-by-alias.marko",
|
|
135
135
|
tags: [
|
|
136
136
|
"../links/set-filter-value.marko",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.68.0/components/filters/website-sections.marko",
|
|
6
6
|
marko_component = require("./website-sections.marko"),
|
|
7
7
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
8
8
|
module_defaultValue = require("@mindful-web/marko-core/utils/default-value"),
|
|
@@ -114,7 +114,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
114
114
|
}, marko_component);
|
|
115
115
|
|
|
116
116
|
marko_template.meta = {
|
|
117
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
117
|
+
id: "/@mindful-web/marko-web-search$1.68.0/components/filters/website-sections.marko",
|
|
118
118
|
component: "./website-sections.marko",
|
|
119
119
|
tags: [
|
|
120
120
|
"../links/set-filter-value.marko",
|
|
@@ -6,10 +6,8 @@ $ const blockName = "marko-web-search-form";
|
|
|
6
6
|
$ const { req, $markoWebSearch: search } = out.global;
|
|
7
7
|
$ const path = defaultValue(input.path, req.path);
|
|
8
8
|
$ const params = search.buildURLSearchParams({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
cursorValue: '',
|
|
12
|
-
}),
|
|
9
|
+
cursorDirection: 'AFTER',
|
|
10
|
+
cursorValue: '',
|
|
13
11
|
page: 1,
|
|
14
12
|
}, { searchQuery: true });
|
|
15
13
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.68.0/components/form/index.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
module_objectPath_module = require("@mindful-web/object-path"),
|
|
8
8
|
objectPath_module = module_objectPath_module.default || module_objectPath_module,
|
|
@@ -30,10 +30,8 @@ function render(input, out, __component, component, state) {
|
|
|
30
30
|
const path = defaultValue(input.path, req.path);
|
|
31
31
|
|
|
32
32
|
const params = search.buildURLSearchParams({
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
cursorValue: '',
|
|
36
|
-
}),
|
|
33
|
+
cursorDirection: 'AFTER',
|
|
34
|
+
cursorValue: '',
|
|
37
35
|
page: 1,
|
|
38
36
|
}, { searchQuery: true });
|
|
39
37
|
|
|
@@ -78,7 +76,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
78
76
|
});
|
|
79
77
|
|
|
80
78
|
marko_template.meta = {
|
|
81
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
79
|
+
id: "/@mindful-web/marko-web-search$1.68.0/components/form/index.marko",
|
|
82
80
|
tags: [
|
|
83
81
|
"@mindful-web/marko-web/components/element/block.marko"
|
|
84
82
|
]
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.68.0/components/form/input.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
marko_mergeAttrs = require("marko/dist/runtime/html/helpers/merge-attrs");
|
|
8
8
|
|
|
@@ -26,5 +26,5 @@ marko_template._ = marko_renderer(render, {
|
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
marko_template.meta = {
|
|
29
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
29
|
+
id: "/@mindful-web/marko-web-search$1.68.0/components/form/input.marko"
|
|
30
30
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.68.0/components/links/link.marko",
|
|
6
6
|
marko_component = require("./link.marko"),
|
|
7
7
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
8
8
|
marko_dynamicTag = require("marko/dist/runtime/helpers/dynamic-tag"),
|
|
@@ -38,7 +38,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
38
38
|
}, marko_component);
|
|
39
39
|
|
|
40
40
|
marko_template.meta = {
|
|
41
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
41
|
+
id: "/@mindful-web/marko-web-search$1.68.0/components/links/link.marko",
|
|
42
42
|
component: "./link.marko",
|
|
43
43
|
tags: [
|
|
44
44
|
"@mindful-web/marko-web/components/element/link.marko",
|
|
@@ -2,22 +2,17 @@ import { isFunction } from '@mindful-web/utils';
|
|
|
2
2
|
import defaultValue from "@mindful-web/marko-core/utils/default-value";
|
|
3
3
|
|
|
4
4
|
$ const { $markoWebSearch: search, i18n } = out.global;
|
|
5
|
-
$ const { useMindful } = search.config;
|
|
6
5
|
$ const pageInfo = defaultValue(input.pageInfo, {});
|
|
7
6
|
$ const { sortField, sortOrder } = search.input;
|
|
8
7
|
|
|
9
|
-
$ const queryValues =
|
|
8
|
+
$ const queryValues = {
|
|
10
9
|
cursorDirection: 'AFTER',
|
|
11
10
|
cursorValue: pageInfo.endCursor,
|
|
12
|
-
sortField,
|
|
13
|
-
|
|
14
|
-
page: search.getNextPage(input.totalCount), sortField, sortOrder
|
|
11
|
+
sortField,
|
|
12
|
+
sortOrder,
|
|
15
13
|
};
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<if(hasNextPage)>
|
|
15
|
+
<if(pageInfo.hasNextPage)>
|
|
21
16
|
<marko-web-search-link
|
|
22
17
|
path=input.path
|
|
23
18
|
query-values=queryValues
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.68.0/components/links/next-page.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
module_utils_module = require("@mindful-web/utils"),
|
|
8
8
|
utils_module = module_utils_module.default || module_utils_module,
|
|
@@ -21,23 +21,18 @@ function render(input, out, __component, component, state) {
|
|
|
21
21
|
|
|
22
22
|
const { $markoWebSearch: search, i18n } = out.global;
|
|
23
23
|
|
|
24
|
-
const { useMindful } = search.config;
|
|
25
|
-
|
|
26
24
|
const pageInfo = defaultValue(input.pageInfo, {});
|
|
27
25
|
|
|
28
26
|
const { sortField, sortOrder } = search.input;
|
|
29
27
|
|
|
30
|
-
const queryValues =
|
|
28
|
+
const queryValues = {
|
|
31
29
|
cursorDirection: 'AFTER',
|
|
32
30
|
cursorValue: pageInfo.endCursor,
|
|
33
|
-
sortField,
|
|
34
|
-
|
|
35
|
-
page: search.getNextPage(input.totalCount), sortField, sortOrder
|
|
31
|
+
sortField,
|
|
32
|
+
sortOrder,
|
|
36
33
|
};
|
|
37
34
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (hasNextPage) {
|
|
35
|
+
if (pageInfo.hasNextPage) {
|
|
41
36
|
marko_web_search_link_tag({
|
|
42
37
|
path: input.path,
|
|
43
38
|
queryValues: queryValues,
|
|
@@ -62,7 +57,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
62
57
|
});
|
|
63
58
|
|
|
64
59
|
marko_template.meta = {
|
|
65
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
60
|
+
id: "/@mindful-web/marko-web-search$1.68.0/components/links/next-page.marko",
|
|
66
61
|
tags: [
|
|
67
62
|
"./link.marko"
|
|
68
63
|
]
|
|
@@ -2,22 +2,17 @@ import { isFunction } from '@mindful-web/utils';
|
|
|
2
2
|
import defaultValue from "@mindful-web/marko-core/utils/default-value";
|
|
3
3
|
|
|
4
4
|
$ const { $markoWebSearch: search, i18n } = out.global;
|
|
5
|
-
$ const { useMindful } = search.config;
|
|
6
5
|
$ const pageInfo = defaultValue(input.pageInfo, {});
|
|
7
6
|
$ const { sortField, sortOrder } = search.input;
|
|
8
7
|
|
|
9
|
-
$ const queryValues =
|
|
8
|
+
$ const queryValues = {
|
|
10
9
|
cursorDirection: 'BEFORE',
|
|
11
10
|
cursorValue: pageInfo.startCursor,
|
|
12
|
-
sortField,
|
|
13
|
-
|
|
14
|
-
page: search.getPrevPage(), sortField, sortOrder
|
|
11
|
+
sortField,
|
|
12
|
+
sortOrder,
|
|
15
13
|
};
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<if(hasPreviousPage)>
|
|
15
|
+
<if(pageInfo.hasPreviousPage)>
|
|
21
16
|
<marko-web-search-link
|
|
22
17
|
path=input.path
|
|
23
18
|
query-values=queryValues
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.68.0/components/links/previous-page.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
module_utils_module = require("@mindful-web/utils"),
|
|
8
8
|
utils_module = module_utils_module.default || module_utils_module,
|
|
@@ -21,23 +21,18 @@ function render(input, out, __component, component, state) {
|
|
|
21
21
|
|
|
22
22
|
const { $markoWebSearch: search, i18n } = out.global;
|
|
23
23
|
|
|
24
|
-
const { useMindful } = search.config;
|
|
25
|
-
|
|
26
24
|
const pageInfo = defaultValue(input.pageInfo, {});
|
|
27
25
|
|
|
28
26
|
const { sortField, sortOrder } = search.input;
|
|
29
27
|
|
|
30
|
-
const queryValues =
|
|
28
|
+
const queryValues = {
|
|
31
29
|
cursorDirection: 'BEFORE',
|
|
32
30
|
cursorValue: pageInfo.startCursor,
|
|
33
|
-
sortField,
|
|
34
|
-
|
|
35
|
-
page: search.getPrevPage(), sortField, sortOrder
|
|
31
|
+
sortField,
|
|
32
|
+
sortOrder,
|
|
36
33
|
};
|
|
37
34
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (hasPreviousPage) {
|
|
35
|
+
if (pageInfo.hasPreviousPage) {
|
|
41
36
|
marko_web_search_link_tag({
|
|
42
37
|
path: input.path,
|
|
43
38
|
queryValues: queryValues,
|
|
@@ -62,7 +57,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
62
57
|
});
|
|
63
58
|
|
|
64
59
|
marko_template.meta = {
|
|
65
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
60
|
+
id: "/@mindful-web/marko-web-search$1.68.0/components/links/previous-page.marko",
|
|
66
61
|
tags: [
|
|
67
62
|
"./link.marko"
|
|
68
63
|
]
|
|
@@ -8,11 +8,9 @@ $ const isDefaultValue = search.isDefaultInputValueFor(name);
|
|
|
8
8
|
$ const queryValues = {
|
|
9
9
|
[name]: null,
|
|
10
10
|
...(resetPage && {
|
|
11
|
+
cursorDirection: 'AFTER',
|
|
12
|
+
cursorValue: '',
|
|
11
13
|
page: 1,
|
|
12
|
-
...(search.config.useMindful && {
|
|
13
|
-
cursorDirection: 'AFTER',
|
|
14
|
-
cursorValue: '',
|
|
15
|
-
}),
|
|
16
14
|
}),
|
|
17
15
|
};
|
|
18
16
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.68.0/components/links/reset-filter.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
module_defaultValue = require("@mindful-web/marko-core/utils/default-value"),
|
|
8
8
|
defaultValue = module_defaultValue.default || module_defaultValue,
|
|
@@ -25,11 +25,9 @@ function render(input, out, __component, component, state) {
|
|
|
25
25
|
const queryValues = {
|
|
26
26
|
[name]: null,
|
|
27
27
|
...(resetPage && {
|
|
28
|
+
cursorDirection: 'AFTER',
|
|
29
|
+
cursorValue: '',
|
|
28
30
|
page: 1,
|
|
29
|
-
...(search.config.useMindful && {
|
|
30
|
-
cursorDirection: 'AFTER',
|
|
31
|
-
cursorValue: '',
|
|
32
|
-
}),
|
|
33
31
|
}),
|
|
34
32
|
};
|
|
35
33
|
|
|
@@ -54,7 +52,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
54
52
|
});
|
|
55
53
|
|
|
56
54
|
marko_template.meta = {
|
|
57
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
55
|
+
id: "/@mindful-web/marko-web-search$1.68.0/components/links/reset-filter.marko",
|
|
58
56
|
tags: [
|
|
59
57
|
"./link.marko"
|
|
60
58
|
]
|
|
@@ -10,11 +10,9 @@ $ const resetPage = defaultValue(input.resetPage, true);
|
|
|
10
10
|
$ const queryValues = {
|
|
11
11
|
[name]: v,
|
|
12
12
|
...(resetPage && {
|
|
13
|
+
cursorDirection: 'AFTER',
|
|
14
|
+
cursorValue: '',
|
|
13
15
|
page: 1,
|
|
14
|
-
...(search.config.useMindful && {
|
|
15
|
-
cursorDirection: 'AFTER',
|
|
16
|
-
cursorValue: '',
|
|
17
|
-
}),
|
|
18
16
|
}),
|
|
19
17
|
};
|
|
20
18
|
$ const resetValues = {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.68.0/components/links/set-filter-value.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
module_defaultValue = require("@mindful-web/marko-core/utils/default-value"),
|
|
8
8
|
defaultValue = module_defaultValue.default || module_defaultValue,
|
|
@@ -29,11 +29,9 @@ function render(input, out, __component, component, state) {
|
|
|
29
29
|
const queryValues = {
|
|
30
30
|
[name]: v,
|
|
31
31
|
...(resetPage && {
|
|
32
|
+
cursorDirection: 'AFTER',
|
|
33
|
+
cursorValue: '',
|
|
32
34
|
page: 1,
|
|
33
|
-
...(search.config.useMindful && {
|
|
34
|
-
cursorDirection: 'AFTER',
|
|
35
|
-
cursorValue: '',
|
|
36
|
-
}),
|
|
37
35
|
}),
|
|
38
36
|
};
|
|
39
37
|
|
|
@@ -85,7 +83,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
85
83
|
});
|
|
86
84
|
|
|
87
85
|
marko_template.meta = {
|
|
88
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
86
|
+
id: "/@mindful-web/marko-web-search$1.68.0/components/links/set-filter-value.marko",
|
|
89
87
|
tags: [
|
|
90
88
|
"./link.marko"
|
|
91
89
|
]
|
|
@@ -3,16 +3,12 @@ import { get } from "@mindful-web/object-path";
|
|
|
3
3
|
import { isFunction } from '@mindful-web/utils';
|
|
4
4
|
|
|
5
5
|
$ const { $markoWebSearch: search, i18n } = out.global;
|
|
6
|
-
$ const { useMindful } = search.config;
|
|
7
6
|
$ const totalCount = defaultValue(input.totalCount, 0);
|
|
8
7
|
$ const pageInfo = defaultValue(input.pageInfo, {});
|
|
9
8
|
$ const linkClasses = get(input.link, "class");
|
|
10
9
|
|
|
11
10
|
$ const blockName = "marko-web-search-pagination-controls";
|
|
12
|
-
$ const showControls = (
|
|
13
|
-
if (useMindful) return true;
|
|
14
|
-
return Boolean(totalCount);
|
|
15
|
-
})();
|
|
11
|
+
$ const showControls = Boolean(pageInfo.hasNextPage || pageInfo.hasPreviousPage || totalCount);
|
|
16
12
|
|
|
17
13
|
<if(showControls)>
|
|
18
14
|
<marko-web-block ...input.block name=blockName>
|
|
@@ -23,23 +19,10 @@ $ const showControls = (() => {
|
|
|
23
19
|
/>
|
|
24
20
|
|
|
25
21
|
<marko-web-element block-name=blockName name="pages">
|
|
26
|
-
<if(
|
|
27
|
-
<!-- only display page counts when _not_ using mindful cursor pagination -->
|
|
22
|
+
<if(input.renderBody)>
|
|
28
23
|
$ const currentPage = search.getCurrentPage(pageInfo);
|
|
29
24
|
$ const totalPages = search.getTotalPages(totalCount, pageInfo);
|
|
30
|
-
|
|
31
|
-
<!-- custom rendering -->
|
|
32
|
-
<${input.renderBody} current-page=currentPage total-pages=totalPages />
|
|
33
|
-
</if>
|
|
34
|
-
<else>
|
|
35
|
-
<!-- default rendering -->
|
|
36
|
-
<if(isFunction(i18n))>
|
|
37
|
-
${i18n("Page")} ${currentPage} ${i18n("of")} ${totalPages}
|
|
38
|
-
</if>
|
|
39
|
-
<else>
|
|
40
|
-
Page ${currentPage} of ${totalPages}
|
|
41
|
-
</else>
|
|
42
|
-
</else>
|
|
25
|
+
<${input.renderBody} current-page=currentPage total-pages=totalPages />
|
|
43
26
|
</if>
|
|
44
27
|
</marko-web-element>
|
|
45
28
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.68.0/components/pagination-controls.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
module_defaultValue = require("@mindful-web/marko-core/utils/default-value"),
|
|
8
8
|
defaultValue = module_defaultValue.default || module_defaultValue,
|
|
@@ -17,8 +17,6 @@ var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
|
17
17
|
marko_loadTag = require("marko/dist/runtime/helpers/load-tag"),
|
|
18
18
|
marko_web_search_previous_page_link_tag = marko_loadTag(marko_web_search_previous_page_link_template),
|
|
19
19
|
marko_dynamicTag = require("marko/dist/runtime/helpers/dynamic-tag"),
|
|
20
|
-
helpers_escape_xml = require("marko/dist/runtime/html/helpers/escape-xml"),
|
|
21
|
-
marko_escapeXml = helpers_escape_xml.x,
|
|
22
20
|
marko_web_element_template = require("@mindful-web/marko-web/components/element/index.marko"),
|
|
23
21
|
marko_web_element_tag = marko_loadTag(marko_web_element_template),
|
|
24
22
|
marko_web_search_next_page_link_template = require("./links/next-page.marko"),
|
|
@@ -31,8 +29,6 @@ function render(input, out, __component, component, state) {
|
|
|
31
29
|
|
|
32
30
|
const { $markoWebSearch: search, i18n } = out.global;
|
|
33
31
|
|
|
34
|
-
const { useMindful } = search.config;
|
|
35
|
-
|
|
36
32
|
const totalCount = defaultValue(input.totalCount, 0);
|
|
37
33
|
|
|
38
34
|
const pageInfo = defaultValue(input.pageInfo, {});
|
|
@@ -41,10 +37,7 @@ function render(input, out, __component, component, state) {
|
|
|
41
37
|
|
|
42
38
|
const blockName = "marko-web-search-pagination-controls";
|
|
43
39
|
|
|
44
|
-
const showControls = (
|
|
45
|
-
if (useMindful) return true;
|
|
46
|
-
return Boolean(totalCount);
|
|
47
|
-
})();
|
|
40
|
+
const showControls = Boolean(pageInfo.hasNextPage || pageInfo.hasPreviousPage || totalCount);
|
|
48
41
|
|
|
49
42
|
if (showControls) {
|
|
50
43
|
marko_web_block_tag(marko_assign({
|
|
@@ -63,34 +56,17 @@ function render(input, out, __component, component, state) {
|
|
|
63
56
|
tag: "div",
|
|
64
57
|
blockName: blockName,
|
|
65
58
|
renderBody: function(out) {
|
|
66
|
-
if (
|
|
59
|
+
if (input.renderBody) {
|
|
67
60
|
const currentPage = search.getCurrentPage(pageInfo);
|
|
68
61
|
|
|
69
62
|
const totalPages = search.getTotalPages(totalCount, pageInfo);
|
|
70
63
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}, null, null, null, __component, "3");
|
|
78
|
-
} else {
|
|
79
|
-
if (isFunction(i18n)) {
|
|
80
|
-
out.w(marko_escapeXml(i18n("Page")) +
|
|
81
|
-
" " +
|
|
82
|
-
marko_escapeXml(currentPage) +
|
|
83
|
-
" " +
|
|
84
|
-
marko_escapeXml(i18n("of")) +
|
|
85
|
-
" " +
|
|
86
|
-
marko_escapeXml(totalPages));
|
|
87
|
-
} else {
|
|
88
|
-
out.w("Page " +
|
|
89
|
-
marko_escapeXml(currentPage) +
|
|
90
|
-
" of " +
|
|
91
|
-
marko_escapeXml(totalPages));
|
|
92
|
-
}
|
|
93
|
-
}
|
|
64
|
+
marko_dynamicTag(out, input.renderBody, function() {
|
|
65
|
+
return {
|
|
66
|
+
"current-page": currentPage,
|
|
67
|
+
"total-pages": totalPages
|
|
68
|
+
};
|
|
69
|
+
}, null, null, null, __component, "3");
|
|
94
70
|
}
|
|
95
71
|
}
|
|
96
72
|
}, out, __component, "2");
|
|
@@ -111,7 +87,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
111
87
|
});
|
|
112
88
|
|
|
113
89
|
marko_template.meta = {
|
|
114
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
90
|
+
id: "/@mindful-web/marko-web-search$1.68.0/components/pagination-controls.marko",
|
|
115
91
|
tags: [
|
|
116
92
|
"./links/previous-page.marko",
|
|
117
93
|
"@mindful-web/marko-web/components/element/index.marko",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.68.0/components/query-child-sections.marko",
|
|
6
6
|
marko_component = require("./query-child-sections.marko"),
|
|
7
7
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
8
8
|
module_gql = require("graphql-tag"),
|
|
@@ -52,7 +52,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
52
52
|
}, marko_component);
|
|
53
53
|
|
|
54
54
|
marko_template.meta = {
|
|
55
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
55
|
+
id: "/@mindful-web/marko-web-search$1.68.0/components/query-child-sections.marko",
|
|
56
56
|
component: "./query-child-sections.marko",
|
|
57
57
|
tags: [
|
|
58
58
|
"@mindful-web/marko-core/components/queries/website-sections.marko"
|
package/components/query.marko
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import loader from "../loaders/search";
|
|
2
|
-
|
|
3
1
|
$ const {
|
|
4
|
-
$baseBrowse: apolloBaseBrowse,
|
|
5
2
|
$markoWebSearch,
|
|
6
3
|
apollo: apolloMindfulWebCMS,
|
|
7
4
|
config,
|
|
@@ -24,22 +21,13 @@ $ const common = {
|
|
|
24
21
|
sortOrder: input.sortOrder,
|
|
25
22
|
};
|
|
26
23
|
|
|
27
|
-
$ const runQuery = () => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
cursorValue: input.cursorValue,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
return loader({ apolloMindfulWebCMS, apolloBaseBrowse }, {
|
|
37
|
-
...common, skip: input.skip, countryCodes: input.countryCodes
|
|
38
|
-
});
|
|
39
|
-
};
|
|
24
|
+
$ const runQuery = () => $markoWebSearch.config.mindful.searchPostsAsContentUsingLegacyParams({
|
|
25
|
+
...common,
|
|
26
|
+
apolloMindfulWebCMS,
|
|
27
|
+
cursorDirection: input.cursorDirection,
|
|
28
|
+
cursorValue: input.cursorValue,
|
|
29
|
+
});
|
|
40
30
|
|
|
41
31
|
<marko-web-resolve|{ resolved }| promise=runQuery()>
|
|
42
32
|
<${input.renderBody} ...resolved />
|
|
43
33
|
</marko-web-resolve>
|
|
44
|
-
|
|
45
|
-
|
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.68.0/components/query.marko",
|
|
6
6
|
marko_component = require("./query.marko"),
|
|
7
7
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
8
|
-
module_loader = require("../loaders/search"),
|
|
9
|
-
loader = module_loader.default || module_loader,
|
|
10
8
|
marko_dynamicTag = require("marko/dist/runtime/helpers/dynamic-tag"),
|
|
11
9
|
marko_web_resolve_template = require("@mindful-web/marko-core/components/resolve.marko"),
|
|
12
10
|
marko_loadTag = require("marko/dist/runtime/helpers/load-tag"),
|
|
@@ -16,7 +14,6 @@ function render(input, out, __component, component, state) {
|
|
|
16
14
|
var data = input;
|
|
17
15
|
|
|
18
16
|
const {
|
|
19
|
-
$baseBrowse: apolloBaseBrowse,
|
|
20
17
|
$markoWebSearch,
|
|
21
18
|
apollo: apolloMindfulWebCMS,
|
|
22
19
|
config,
|
|
@@ -40,19 +37,12 @@ function render(input, out, __component, component, state) {
|
|
|
40
37
|
sortOrder: input.sortOrder,
|
|
41
38
|
};
|
|
42
39
|
|
|
43
|
-
const runQuery = () => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
cursorValue: input.cursorValue,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
return loader({ apolloMindfulWebCMS, apolloBaseBrowse }, {
|
|
53
|
-
...common, skip: input.skip, countryCodes: input.countryCodes
|
|
54
|
-
});
|
|
55
|
-
};
|
|
40
|
+
const runQuery = () => $markoWebSearch.config.mindful.searchPostsAsContentUsingLegacyParams({
|
|
41
|
+
...common,
|
|
42
|
+
apolloMindfulWebCMS,
|
|
43
|
+
cursorDirection: input.cursorDirection,
|
|
44
|
+
cursorValue: input.cursorValue,
|
|
45
|
+
});
|
|
56
46
|
|
|
57
47
|
marko_web_resolve_tag({
|
|
58
48
|
promise: runQuery(),
|
|
@@ -69,7 +59,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
69
59
|
}, marko_component);
|
|
70
60
|
|
|
71
61
|
marko_template.meta = {
|
|
72
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
62
|
+
id: "/@mindful-web/marko-web-search$1.68.0/components/query.marko",
|
|
73
63
|
component: "./query.marko",
|
|
74
64
|
tags: [
|
|
75
65
|
"@mindful-web/marko-core/components/resolve.marko"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var marko_template = module.exports = require("marko/dist/html").t(__filename),
|
|
5
|
-
marko_componentType = "/@mindful-web/marko-web-search$1.
|
|
5
|
+
marko_componentType = "/@mindful-web/marko-web-search$1.68.0/components/sort-by/index.marko",
|
|
6
6
|
marko_renderer = require("marko/dist/runtime/components/renderer"),
|
|
7
7
|
module_objectPath_module = require("@mindful-web/object-path"),
|
|
8
8
|
objectPath_module = module_objectPath_module.default || module_objectPath_module,
|
|
@@ -64,7 +64,7 @@ marko_template._ = marko_renderer(render, {
|
|
|
64
64
|
});
|
|
65
65
|
|
|
66
66
|
marko_template.meta = {
|
|
67
|
-
id: "/@mindful-web/marko-web-search$1.
|
|
67
|
+
id: "/@mindful-web/marko-web-search$1.68.0/components/sort-by/index.marko",
|
|
68
68
|
tags: [
|
|
69
69
|
"@mindful-web/marko-web/components/browser-component.marko",
|
|
70
70
|
"@mindful-web/marko-web/components/element/block.marko"
|
package/config/index.js
CHANGED
|
@@ -19,7 +19,6 @@ class MarkoWebSearchConfig {
|
|
|
19
19
|
mindful,
|
|
20
20
|
resultsPerPage,
|
|
21
21
|
rootAlias,
|
|
22
|
-
useMindful,
|
|
23
22
|
} = validate(Joi.object({
|
|
24
23
|
resultsPerPage: Joi.object({
|
|
25
24
|
min: Joi.number().integer().default(1),
|
|
@@ -62,10 +61,9 @@ class MarkoWebSearchConfig {
|
|
|
62
61
|
|
|
63
62
|
this.assignedToWebsiteSectionIds = assignedToWebsiteSectionIds;
|
|
64
63
|
|
|
65
|
-
if (
|
|
66
|
-
throw new Error('In order to use
|
|
64
|
+
if (!mindful) {
|
|
65
|
+
throw new Error('In order to use Mindful search, you must provide the Mindful service');
|
|
67
66
|
}
|
|
68
|
-
this.useMindful = useMindful;
|
|
69
67
|
this.mindful = mindful;
|
|
70
68
|
|
|
71
69
|
this.queryParams = new MarkoWebSearchQueryParamConfig({
|
|
@@ -88,8 +86,7 @@ class MarkoWebSearchConfig {
|
|
|
88
86
|
* @prop {object[]} assignedToWebsiteSectionIds The allowed website section filters. Defaults to
|
|
89
87
|
* none. Should be an array of section IDs, e.g. `[123, 321]`
|
|
90
88
|
* @prop {string} rootAlias The root alias for the search page defaults to 'search'
|
|
91
|
-
* @prop {import("@mindful-web/mindful/marko-web/service").MindfulMarkoWebService}
|
|
92
|
-
* @prop {boolean} [useMindful]
|
|
89
|
+
* @prop {import("@mindful-web/mindful/marko-web/service").MindfulMarkoWebService} mindful
|
|
93
90
|
*/
|
|
94
91
|
|
|
95
92
|
module.exports = MarkoWebSearchConfig;
|
package/index.js
CHANGED
|
@@ -98,8 +98,8 @@ class MarkoWebSearch {
|
|
|
98
98
|
* @param {PageInfo} [pageInfo]
|
|
99
99
|
*/
|
|
100
100
|
getCurrentPage(pageInfo) {
|
|
101
|
-
if (
|
|
102
|
-
return 1;
|
|
101
|
+
if (pageInfo) {
|
|
102
|
+
return ((pageInfo.startingPosition - 1) / this.getLimit()) + 1;
|
|
103
103
|
}
|
|
104
104
|
return this.getInputValueFor('page');
|
|
105
105
|
}
|
|
@@ -119,7 +119,7 @@ class MarkoWebSearch {
|
|
|
119
119
|
getTotalPages(totalCount, pageInfo) {
|
|
120
120
|
const total = totalCount || 0;
|
|
121
121
|
|
|
122
|
-
if (
|
|
122
|
+
if (pageInfo) {
|
|
123
123
|
return Math.ceil(total / this.getLimit());
|
|
124
124
|
}
|
|
125
125
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mindful-web/marko-web-search",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.68.0",
|
|
4
4
|
"author": "Jacob Bare <jacob@parameter1.com>",
|
|
5
5
|
"repository": "https://github.com/parameter1/mindful-web/tree/main/packages/marko-web-search",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "c7b9eeab22222e27f7513dfafaec97eac82b2c69"
|
|
32
32
|
}
|
package/loaders/search.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
const gql = require('graphql-tag');
|
|
2
|
-
const { extractFragmentData } = require('@mindful-web/web-common/utils');
|
|
3
|
-
|
|
4
|
-
const buildMindfulWebQuery = ({ queryFragment, opSuffix = '' } = {}) => {
|
|
5
|
-
const { spreadFragmentName, processedFragment } = extractFragmentData(queryFragment);
|
|
6
|
-
return gql`
|
|
7
|
-
query MarkoWebSearchContentIdsFromBrowse${opSuffix}($ids: [Int!]!, $limit: Int!) {
|
|
8
|
-
allContent(input: { ids: $ids, pagination: { limit: $limit } }) {
|
|
9
|
-
edges {
|
|
10
|
-
node {
|
|
11
|
-
id
|
|
12
|
-
${spreadFragmentName}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
${processedFragment}
|
|
18
|
-
`;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const baseBrowseQuery = gql`
|
|
22
|
-
query MarkoWebSearchSearchContentIds($input: BrowseContentQueryInput!) {
|
|
23
|
-
searchContentIds(input: $input) {
|
|
24
|
-
totalCount
|
|
25
|
-
pageInfo {
|
|
26
|
-
hasNextPage
|
|
27
|
-
hasPreviousPage
|
|
28
|
-
}
|
|
29
|
-
ids
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
`;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @param {object} clients
|
|
36
|
-
* @param {ApolloClient} clients.apolloMindfulWebCMS The Mindful Web client that will perform the
|
|
37
|
-
* query.
|
|
38
|
-
* @param {ApolloClient} clients.apolloBaseBrowse The BaseBrowse client that will perform the query.
|
|
39
|
-
* @param {object} params
|
|
40
|
-
* @param {number} [params.limit]
|
|
41
|
-
* @param {number} [params.skip]
|
|
42
|
-
* @param {string} [params.sortField=PUBLISHED]
|
|
43
|
-
* @param {string} [params.sortOrder=DESC]
|
|
44
|
-
* @param {string} [params.searchQuery]
|
|
45
|
-
* @param {string[]} [params.contentTypes]
|
|
46
|
-
* @param {string[]} [params.countryCodes]
|
|
47
|
-
* @param {string[]} [params.assignedToWebsiteSiteIds]
|
|
48
|
-
* @param {number[]} [params.assignedToWebsiteSectionIds]
|
|
49
|
-
* @param {string} [params.queryFragment] The `graphql-tag` fragment
|
|
50
|
-
* to apply to the `allContent` query.
|
|
51
|
-
* @param {string} [params.opSuffix] A suffix to add to the GraphQL operation name.
|
|
52
|
-
*/
|
|
53
|
-
module.exports = async ({ apolloMindfulWebCMS, apolloBaseBrowse } = {}, {
|
|
54
|
-
limit,
|
|
55
|
-
skip,
|
|
56
|
-
|
|
57
|
-
sortField = 'PUBLISHED',
|
|
58
|
-
sortOrder = 'DESC',
|
|
59
|
-
|
|
60
|
-
searchQuery,
|
|
61
|
-
contentTypes = [],
|
|
62
|
-
countryCodes = [],
|
|
63
|
-
assignedToWebsiteSiteIds = [],
|
|
64
|
-
assignedToWebsiteSectionIds = [],
|
|
65
|
-
|
|
66
|
-
queryFragment,
|
|
67
|
-
opSuffix,
|
|
68
|
-
searchType,
|
|
69
|
-
} = {}) => {
|
|
70
|
-
if (!apolloMindfulWebCMS || !apolloBaseBrowse) throw new Error('Both the Mindful Web and Base Browse Apollo clients must be provided.');
|
|
71
|
-
const input = {
|
|
72
|
-
omitScheduledAndExpiredContent: true,
|
|
73
|
-
statuses: ['PUBLISHED'],
|
|
74
|
-
contentTypes,
|
|
75
|
-
countryCodes,
|
|
76
|
-
...(searchQuery && { search: { query: searchQuery, type: searchType } }),
|
|
77
|
-
...((assignedToWebsiteSiteIds.length || assignedToWebsiteSectionIds.length) && {
|
|
78
|
-
assignedToWebsites: {
|
|
79
|
-
...(assignedToWebsiteSiteIds.length && { siteIds: assignedToWebsiteSiteIds }),
|
|
80
|
-
...(assignedToWebsiteSectionIds.length && { sectionIds: assignedToWebsiteSectionIds }),
|
|
81
|
-
},
|
|
82
|
-
}),
|
|
83
|
-
pagination: { limit, skip },
|
|
84
|
-
sort: {
|
|
85
|
-
field: sortField,
|
|
86
|
-
order: sortOrder,
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const { data: baseBrowseData } = await apolloBaseBrowse.query({
|
|
91
|
-
query: baseBrowseQuery,
|
|
92
|
-
variables: { input },
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
const { ids, pageInfo, totalCount } = baseBrowseData.searchContentIds;
|
|
96
|
-
if (!ids.length) return { nodes: [], pageInfo, totalCount };
|
|
97
|
-
|
|
98
|
-
const { data } = await apolloMindfulWebCMS.query({
|
|
99
|
-
query: buildMindfulWebQuery({ queryFragment, opSuffix }),
|
|
100
|
-
variables: { ids, limit: ids.length },
|
|
101
|
-
});
|
|
102
|
-
const nodes = data.allContent.edges
|
|
103
|
-
.map((edge) => (edge && edge.node ? edge.node : null))
|
|
104
|
-
.filter((c) => c);
|
|
105
|
-
const map = nodes.reduce((m, node) => m.set(`${node.id}`, node), new Map());
|
|
106
|
-
const ordered = ids.map((id) => map.get(`${id}`)).filter((node) => node);
|
|
107
|
-
return { nodes: ordered, pageInfo, totalCount };
|
|
108
|
-
};
|