@projectdochelp/s3te 3.4.1 → 3.4.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/README.md
CHANGED
|
@@ -724,7 +724,8 @@ Filter notes:
|
|
|
724
724
|
- multiple clauses are combined with logical `AND`
|
|
725
725
|
- `__typename` matches the content model, for example `article`
|
|
726
726
|
- supported legacy value wrappers are `S`, `N`, `BOOL`, `NULL`, and `L`
|
|
727
|
-
- results are sorted deterministically; numeric `order`
|
|
727
|
+
- results are sorted deterministically; items with a numeric field `order` are rendered first in ascending order, then items without a numeric `order`, then `contentId`, then `id`
|
|
728
|
+
- this also works with mirrored Webiny content if the model contains a field with the exact field ID `order` and type `number`
|
|
728
729
|
|
|
729
730
|
**Example**
|
|
730
731
|
|
|
@@ -1018,6 +1019,13 @@ That makes the option example above equivalent to a config that contains:
|
|
|
1018
1019
|
|
|
1019
1020
|
Use this for every Webiny model whose entries should be available to S3TE template commands like `dbitem`, `dbmulti`, `dbmultifile`, `dbmultifileitem`, or `dbpart`.
|
|
1020
1021
|
|
|
1022
|
+
If a Webiny model should control the output order for `dbmulti` or `dbmultifile`, add a field with:
|
|
1023
|
+
|
|
1024
|
+
- field ID `order`
|
|
1025
|
+
- field type `number`
|
|
1026
|
+
|
|
1027
|
+
S3TE sorts matching items by that numeric `order` in ascending order. Items without a numeric `order` stay at the end.
|
|
1028
|
+
|
|
1021
1029
|
If different environments should read from different Webiny installations or tenants, run the option command per environment:
|
|
1022
1030
|
|
|
1023
1031
|
```bash
|
package/package.json
CHANGED
|
@@ -7,6 +7,12 @@ function normalizeKey(value) {
|
|
|
7
7
|
return String(value).replace(/\\/g, "/");
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
function matchesProjectRelativeRoot(key, root) {
|
|
11
|
+
const normalizedKey = normalizeKey(key);
|
|
12
|
+
const normalizedRoot = normalizeKey(root);
|
|
13
|
+
return normalizedKey === normalizedRoot || normalizedKey.startsWith(`${normalizedRoot}/`);
|
|
14
|
+
}
|
|
15
|
+
|
|
10
16
|
function normalizeLocale(value) {
|
|
11
17
|
return String(value).trim().toLowerCase();
|
|
12
18
|
}
|
|
@@ -122,6 +128,15 @@ export class FileSystemTemplateRepository {
|
|
|
122
128
|
resolveKey(key) {
|
|
123
129
|
const normalized = normalizeKey(key);
|
|
124
130
|
|
|
131
|
+
for (const variantConfig of Object.values(this.config.variants)) {
|
|
132
|
+
if (
|
|
133
|
+
matchesProjectRelativeRoot(normalized, variantConfig.sourceDir)
|
|
134
|
+
|| matchesProjectRelativeRoot(normalized, variantConfig.partDir)
|
|
135
|
+
) {
|
|
136
|
+
return path.join(this.projectDir, normalized);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
125
140
|
for (const [variantName, variantConfig] of Object.entries(this.config.variants)) {
|
|
126
141
|
if (normalized === variantName || normalized.startsWith(`${variantName}/`)) {
|
|
127
142
|
const suffix = normalized === variantName ? "" : normalized.slice(variantName.length + 1);
|
|
@@ -83,13 +83,42 @@ function compareFilter(actual, expected, filterType) {
|
|
|
83
83
|
return actual === expected;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
function coerceNumericOrderValue(value) {
|
|
87
|
+
if (typeof value === "number") {
|
|
88
|
+
return Number.isFinite(value) ? value : null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (typeof value === "string") {
|
|
92
|
+
const trimmed = value.trim();
|
|
93
|
+
if (!trimmed) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
const parsed = Number(trimmed);
|
|
97
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const legacyValue = legacyAttributeValueToPlain(value);
|
|
101
|
+
if (legacyValue !== undefined && legacyValue !== value) {
|
|
102
|
+
return coerceNumericOrderValue(legacyValue);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function readOrderValue(item) {
|
|
109
|
+
const candidate = item?.values?.order ?? item?.order;
|
|
110
|
+
return coerceNumericOrderValue(candidate);
|
|
111
|
+
}
|
|
112
|
+
|
|
86
113
|
function compareOrder(a, b) {
|
|
87
|
-
const
|
|
88
|
-
const
|
|
114
|
+
const aOrder = readOrderValue(a);
|
|
115
|
+
const bOrder = readOrderValue(b);
|
|
116
|
+
const aHasOrder = aOrder !== null;
|
|
117
|
+
const bHasOrder = bOrder !== null;
|
|
89
118
|
|
|
90
119
|
if (aHasOrder && bHasOrder) {
|
|
91
|
-
if (
|
|
92
|
-
return
|
|
120
|
+
if (aOrder !== bOrder) {
|
|
121
|
+
return aOrder - bOrder;
|
|
93
122
|
}
|
|
94
123
|
} else if (aHasOrder && !bHasOrder) {
|
|
95
124
|
return -1;
|