@adobe/helix-html-pipeline 5.13.11 → 5.13.12
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
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [5.13.12](https://github.com/adobe/helix-html-pipeline/compare/v5.13.11...v5.13.12) (2024-12-04)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* apply folder-mapped metadata also for existing resources ([#766](https://github.com/adobe/helix-html-pipeline/issues/766)) ([9574186](https://github.com/adobe/helix-html-pipeline/commit/95741861927afe291cd63ca4502e9c52d2e215fa)), closes [#758](https://github.com/adobe/helix-html-pipeline/issues/758)
|
|
7
|
+
|
|
1
8
|
## [5.13.11](https://github.com/adobe/helix-html-pipeline/compare/v5.13.10...v5.13.11) (2024-11-23)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-html-pipeline",
|
|
3
|
-
"version": "5.13.
|
|
3
|
+
"version": "5.13.12",
|
|
4
4
|
"description": "Helix HTML Pipeline",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"jsdom": "25.0.1",
|
|
90
90
|
"junit-report-builder": "5.1.1",
|
|
91
91
|
"lint-staged": "15.2.10",
|
|
92
|
-
"mocha": "
|
|
92
|
+
"mocha": "11.0.1",
|
|
93
93
|
"mocha-multi-reporters": "1.5.1",
|
|
94
94
|
"mocha-suppress-logs": "0.5.1",
|
|
95
95
|
"semantic-release": "24.2.0"
|
package/src/PipelineState.d.ts
CHANGED
|
@@ -133,5 +133,23 @@ declare class PipelineState {
|
|
|
133
133
|
* this is initialized after the config is loaded.
|
|
134
134
|
*/
|
|
135
135
|
liveHost?: string;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* specifies if the content as folder mapped (note that it remains false for content that
|
|
139
|
+
* exists below a folder mapped path. in this case, the `mappedPath` would still be different
|
|
140
|
+
* from the `info.path`
|
|
141
|
+
*/
|
|
142
|
+
mapped: boolean;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* the mapped path (target) of a folder mapping. this is set irrespective of the existence of the
|
|
146
|
+
* resource, when the path is below a folder mapped path
|
|
147
|
+
*/
|
|
148
|
+
mappedPath: string;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* metadata from folder mapping
|
|
152
|
+
*/
|
|
153
|
+
mappedMetadata: Modifiers
|
|
136
154
|
}
|
|
137
155
|
|
package/src/html-pipe.js
CHANGED
|
@@ -20,7 +20,7 @@ import fetchContent from './steps/fetch-content.js';
|
|
|
20
20
|
import fetch404 from './steps/fetch-404.js';
|
|
21
21
|
import fetchConfigAll from './steps/fetch-config-all.js';
|
|
22
22
|
import fixSections from './steps/fix-sections.js';
|
|
23
|
-
import
|
|
23
|
+
import { calculateFolderMapping, applyFolderMapping } from './steps/folder-mapping.js';
|
|
24
24
|
import getMetadata from './steps/get-metadata.js';
|
|
25
25
|
import html from './steps/make-html.js';
|
|
26
26
|
import parseMarkdown from './steps/parse-markdown.js';
|
|
@@ -126,7 +126,7 @@ export async function htmlPipe(state, req) {
|
|
|
126
126
|
state.content.sourceBus = 'code';
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
calculateFolderMapping(state);
|
|
130
130
|
state.timer?.update('content-fetch');
|
|
131
131
|
let contentPromise = await fetchContent(state, req, res);
|
|
132
132
|
if (res.status === 404) {
|
|
@@ -135,7 +135,7 @@ export async function htmlPipe(state, req) {
|
|
|
135
135
|
contentPromise = fetchContentRedirectWith404Fallback(state, req, res);
|
|
136
136
|
} else {
|
|
137
137
|
// ...apply folder mapping if the current resource doesn't exist
|
|
138
|
-
|
|
138
|
+
applyFolderMapping(state);
|
|
139
139
|
if (state.info.unmappedPath) {
|
|
140
140
|
contentPromise = fetchContentWith404Fallback(state, req, res);
|
|
141
141
|
} else {
|
|
@@ -168,7 +168,7 @@ export default function extractMetaData(state, req) {
|
|
|
168
168
|
// with local metadata from document
|
|
169
169
|
const metaConfig = Object.assign(
|
|
170
170
|
state.metadata.getModifiers(state.info.unmappedPath || state.info.path),
|
|
171
|
-
state.mappedMetadata.getModifiers(state.info.unmappedPath),
|
|
171
|
+
state.mappedMetadata.getModifiers(state.info.unmappedPath || state.info.path),
|
|
172
172
|
);
|
|
173
173
|
|
|
174
174
|
// prune empty values and explicit "" strings from sheet based metadata
|
|
@@ -24,11 +24,12 @@ import { Modifiers } from '../utils/modifiers.js';
|
|
|
24
24
|
*/
|
|
25
25
|
export default async function fetchMappedMetadata(state) {
|
|
26
26
|
state.mappedMetadata = Modifiers.EMPTY;
|
|
27
|
-
|
|
27
|
+
const { mappedPath } = state;
|
|
28
|
+
if (!mappedPath) {
|
|
28
29
|
return;
|
|
29
30
|
}
|
|
30
31
|
const { contentBusId, partition } = state;
|
|
31
|
-
const metadataPath = `${
|
|
32
|
+
const metadataPath = `${mappedPath}/metadata.json`;
|
|
32
33
|
const key = `${contentBusId}/${partition}${metadataPath}`;
|
|
33
34
|
const ret = await state.s3Loader.getObject('helix-content-bus', key);
|
|
34
35
|
if (ret.status === 200) {
|
|
@@ -33,26 +33,35 @@ export function mapPath(folders, path) {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* Checks the
|
|
37
|
-
*
|
|
36
|
+
* Checks if the resource path is below a folder-mapped configuration and updates `state.mappedPath`
|
|
37
|
+
* accordingly.
|
|
38
38
|
*
|
|
39
|
-
* @
|
|
40
|
-
* @param {PipelineState} state
|
|
39
|
+
* @param state
|
|
41
40
|
*/
|
|
42
|
-
export
|
|
41
|
+
export function calculateFolderMapping(state) {
|
|
43
42
|
const folders = state.helixConfig?.fstab?.data.folders;
|
|
44
43
|
if (!folders) {
|
|
45
44
|
return;
|
|
46
45
|
}
|
|
47
46
|
const { path } = state.info;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
state.mappedPath = mapPath(folders, path);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Applies folder mapping if the resource is mapped (i.e. if `state.mappedPath` is {@code true}.
|
|
52
|
+
*
|
|
53
|
+
* @type PipelineStep
|
|
54
|
+
* @param {PipelineState} state
|
|
55
|
+
*/
|
|
56
|
+
export function applyFolderMapping(state) {
|
|
57
|
+
const { info: { path }, mappedPath } = state;
|
|
58
|
+
if (mappedPath) {
|
|
59
|
+
state.info = getPathInfo(mappedPath);
|
|
51
60
|
state.info.unmappedPath = path;
|
|
52
|
-
if (getExtension(
|
|
61
|
+
if (getExtension(mappedPath)) {
|
|
53
62
|
// special case: use code-bus
|
|
54
63
|
state.content.sourceBus = 'code';
|
|
55
|
-
state.info.resourcePath =
|
|
64
|
+
state.info.resourcePath = mappedPath;
|
|
56
65
|
state.log.info(`mapped ${path} to ${state.info.resourcePath} (code-bus)`);
|
|
57
66
|
} else {
|
|
58
67
|
state.mapped = true;
|