@adobe/helix-html-pipeline 1.5.4 → 1.5.7
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 +21 -0
- package/docs/API.md +244 -5
- package/package.json +3 -14
- package/src/PipelineContent.d.ts +2 -2
- package/src/PipelineContent.js +2 -2
- package/src/utils/id-slugger.js +38 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
## [1.5.7](https://github.com/adobe/helix-html-pipeline/compare/v1.5.6...v1.5.7) (2022-05-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** update dependency @adobe/helix-markdown-support to v3.1.5 ([10b3bb9](https://github.com/adobe/helix-html-pipeline/commit/10b3bb9175685b0367d1e834054974bc4da25b6e))
|
|
7
|
+
|
|
8
|
+
## [1.5.6](https://github.com/adobe/helix-html-pipeline/compare/v1.5.5...v1.5.6) (2022-05-17)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* avoid leading digits in heading ids ([#60](https://github.com/adobe/helix-html-pipeline/issues/60)) ([b2af7bf](https://github.com/adobe/helix-html-pipeline/commit/b2af7bf23f8479ba31c410d5b0a3316bbe071481)), closes [#59](https://github.com/adobe/helix-html-pipeline/issues/59)
|
|
14
|
+
|
|
15
|
+
## [1.5.5](https://github.com/adobe/helix-html-pipeline/compare/v1.5.4...v1.5.5) (2022-05-16)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **deps:** update dependency @adobe/helix-shared-utils to v2.0.10 ([#58](https://github.com/adobe/helix-html-pipeline/issues/58)) ([2761635](https://github.com/adobe/helix-html-pipeline/commit/2761635b891e76a6f16f0bc817abc7f2b7c28979))
|
|
21
|
+
|
|
1
22
|
## [1.5.4](https://github.com/adobe/helix-html-pipeline/compare/v1.5.3...v1.5.4) (2022-05-10)
|
|
2
23
|
|
|
3
24
|
|
package/docs/API.md
CHANGED
|
@@ -1,12 +1,251 @@
|
|
|
1
|
-
|
|
1
|
+
## Classes
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
<dl>
|
|
4
|
+
<dt><a href="#PipelineState">PipelineState</a></dt>
|
|
5
|
+
<dd></dd>
|
|
6
|
+
<dt><a href="#PipelineRequest">PipelineRequest</a></dt>
|
|
7
|
+
<dd></dd>
|
|
8
|
+
<dt><a href="#PipelineResponse">PipelineResponse</a></dt>
|
|
9
|
+
<dd></dd>
|
|
10
|
+
<dt><a href="#PipelineState">PipelineState</a></dt>
|
|
11
|
+
<dd></dd>
|
|
12
|
+
</dl>
|
|
13
|
+
|
|
14
|
+
## Functions
|
|
15
|
+
|
|
16
|
+
<dl>
|
|
17
|
+
<dt><a href="#searchParamsToObject">searchParamsToObject(searchParams)</a> ⇒ <code>Object</code></dt>
|
|
18
|
+
<dd><p>Converts URLSearchParams to an object</p>
|
|
19
|
+
</dd>
|
|
20
|
+
<dt><a href="#extractBodyData">extractBodyData(request)</a> ⇒ <code>Object</code></dt>
|
|
21
|
+
<dd><p>Extracts and parses the body data from the request</p>
|
|
22
|
+
</dd>
|
|
23
|
+
<dt><a href="#formsPipe">formsPipe(state, request)</a> ⇒ <code><a href="#PipelineResponse">Promise.<PipelineResponse></a></code></dt>
|
|
24
|
+
<dd><p>Handle a pipeline POST request.
|
|
25
|
+
At this point POST's only apply to json files that are backed by a workbook.</p>
|
|
26
|
+
</dd>
|
|
27
|
+
<dt><a href="#htmlPipe">htmlPipe(state, req)</a> ⇒ <code><a href="#PipelineResponse">PipelineResponse</a></code></dt>
|
|
28
|
+
<dd><p>Runs the default pipeline and returns the response.</p>
|
|
29
|
+
</dd>
|
|
30
|
+
<dt><a href="#jsonPipe">jsonPipe(state, req)</a> ⇒ <code><a href="#PipelineResponse">PipelineResponse</a></code></dt>
|
|
31
|
+
<dd><p>Runs the default pipeline and returns the response.</p>
|
|
32
|
+
</dd>
|
|
33
|
+
<dt><a href="#optionsPipe">optionsPipe(state, request)</a> ⇒ <code>Response</code></dt>
|
|
34
|
+
<dd><p>Handles options requests</p>
|
|
35
|
+
</dd>
|
|
36
|
+
</dl>
|
|
37
|
+
|
|
38
|
+
<a name="PipelineState"></a>
|
|
39
|
+
|
|
40
|
+
## PipelineState
|
|
41
|
+
**Kind**: global class
|
|
42
|
+
|
|
43
|
+
* [PipelineState](#PipelineState)
|
|
44
|
+
* [new PipelineState()](#new_PipelineState_new)
|
|
45
|
+
* [new PipelineState()](#new_PipelineState_new)
|
|
46
|
+
* [.PipelineState](#PipelineState+PipelineState)
|
|
47
|
+
* [new exports.PipelineState(opts)](#new_PipelineState+PipelineState_new)
|
|
48
|
+
|
|
49
|
+
<a name="new_PipelineState_new"></a>
|
|
50
|
+
|
|
51
|
+
### new PipelineState()
|
|
52
|
+
State of the pipeline
|
|
53
|
+
|
|
54
|
+
<a name="new_PipelineState_new"></a>
|
|
55
|
+
|
|
56
|
+
### new PipelineState()
|
|
57
|
+
State of the pipeline
|
|
58
|
+
|
|
59
|
+
<a name="PipelineState+PipelineState"></a>
|
|
60
|
+
|
|
61
|
+
### pipelineState.PipelineState
|
|
62
|
+
**Kind**: instance class of [<code>PipelineState</code>](#PipelineState)
|
|
63
|
+
<a name="new_PipelineState+PipelineState_new"></a>
|
|
64
|
+
|
|
65
|
+
#### new exports.PipelineState(opts)
|
|
66
|
+
Creates the pipeline state
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
| Param | Type |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| opts | <code>PipelineOptions</code> |
|
|
72
|
+
|
|
73
|
+
<a name="PipelineRequest"></a>
|
|
74
|
+
|
|
75
|
+
## PipelineRequest
|
|
76
|
+
**Kind**: global class
|
|
77
|
+
|
|
78
|
+
* [PipelineRequest](#PipelineRequest)
|
|
79
|
+
* [new PipelineRequest()](#new_PipelineRequest_new)
|
|
80
|
+
* [.PipelineRequest](#PipelineRequest+PipelineRequest)
|
|
81
|
+
* [new exports.PipelineRequest(url, [init])](#new_PipelineRequest+PipelineRequest_new)
|
|
82
|
+
|
|
83
|
+
<a name="new_PipelineRequest_new"></a>
|
|
84
|
+
|
|
85
|
+
### new PipelineRequest()
|
|
86
|
+
Request of a pipeline
|
|
87
|
+
|
|
88
|
+
<a name="PipelineRequest+PipelineRequest"></a>
|
|
89
|
+
|
|
90
|
+
### pipelineRequest.PipelineRequest
|
|
91
|
+
**Kind**: instance class of [<code>PipelineRequest</code>](#PipelineRequest)
|
|
92
|
+
<a name="new_PipelineRequest+PipelineRequest_new"></a>
|
|
93
|
+
|
|
94
|
+
#### new exports.PipelineRequest(url, [init])
|
|
95
|
+
Creates the pipeline request
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
| Param | Type |
|
|
99
|
+
| --- | --- |
|
|
100
|
+
| url | <code>URL</code> \| <code>string</code> |
|
|
101
|
+
| [init] | <code>PipelineRequestInit</code> |
|
|
102
|
+
|
|
103
|
+
<a name="PipelineResponse"></a>
|
|
104
|
+
|
|
105
|
+
## PipelineResponse
|
|
106
|
+
**Kind**: global class
|
|
107
|
+
|
|
108
|
+
* [PipelineResponse](#PipelineResponse)
|
|
109
|
+
* [new PipelineResponse()](#new_PipelineResponse_new)
|
|
110
|
+
* [.PipelineResponse](#PipelineResponse+PipelineResponse)
|
|
111
|
+
* [new exports.PipelineResponse()](#new_PipelineResponse+PipelineResponse_new)
|
|
112
|
+
* [.json()](#PipelineResponse+json) ⇒ <code>object</code>
|
|
113
|
+
|
|
114
|
+
<a name="new_PipelineResponse_new"></a>
|
|
115
|
+
|
|
116
|
+
### new PipelineResponse()
|
|
117
|
+
Response of a pipeline
|
|
118
|
+
|
|
119
|
+
<a name="PipelineResponse+PipelineResponse"></a>
|
|
120
|
+
|
|
121
|
+
### pipelineResponse.PipelineResponse
|
|
122
|
+
**Kind**: instance class of [<code>PipelineResponse</code>](#PipelineResponse)
|
|
123
|
+
<a name="new_PipelineResponse+PipelineResponse_new"></a>
|
|
124
|
+
|
|
125
|
+
#### new exports.PipelineResponse()
|
|
126
|
+
Creates the pipeline response
|
|
127
|
+
|
|
128
|
+
<a name="PipelineResponse+json"></a>
|
|
129
|
+
|
|
130
|
+
### pipelineResponse.json() ⇒ <code>object</code>
|
|
131
|
+
Returns the json parsed object of `this.body`.
|
|
132
|
+
|
|
133
|
+
**Kind**: instance method of [<code>PipelineResponse</code>](#PipelineResponse)
|
|
134
|
+
<a name="PipelineState"></a>
|
|
135
|
+
|
|
136
|
+
## PipelineState
|
|
137
|
+
**Kind**: global class
|
|
138
|
+
|
|
139
|
+
* [PipelineState](#PipelineState)
|
|
140
|
+
* [new PipelineState()](#new_PipelineState_new)
|
|
141
|
+
* [new PipelineState()](#new_PipelineState_new)
|
|
142
|
+
* [.PipelineState](#PipelineState+PipelineState)
|
|
143
|
+
* [new exports.PipelineState(opts)](#new_PipelineState+PipelineState_new)
|
|
144
|
+
|
|
145
|
+
<a name="new_PipelineState_new"></a>
|
|
146
|
+
|
|
147
|
+
### new PipelineState()
|
|
148
|
+
State of the pipeline
|
|
149
|
+
|
|
150
|
+
<a name="new_PipelineState_new"></a>
|
|
151
|
+
|
|
152
|
+
### new PipelineState()
|
|
153
|
+
State of the pipeline
|
|
154
|
+
|
|
155
|
+
<a name="PipelineState+PipelineState"></a>
|
|
156
|
+
|
|
157
|
+
### pipelineState.PipelineState
|
|
158
|
+
**Kind**: instance class of [<code>PipelineState</code>](#PipelineState)
|
|
159
|
+
<a name="new_PipelineState+PipelineState_new"></a>
|
|
160
|
+
|
|
161
|
+
#### new exports.PipelineState(opts)
|
|
162
|
+
Creates the pipeline state
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
| Param | Type |
|
|
166
|
+
| --- | --- |
|
|
167
|
+
| opts | <code>PipelineOptions</code> |
|
|
168
|
+
|
|
169
|
+
<a name="searchParamsToObject"></a>
|
|
170
|
+
|
|
171
|
+
## searchParamsToObject(searchParams) ⇒ <code>Object</code>
|
|
172
|
+
Converts URLSearchParams to an object
|
|
173
|
+
|
|
174
|
+
**Kind**: global function
|
|
175
|
+
**Returns**: <code>Object</code> - The converted object
|
|
176
|
+
|
|
177
|
+
| Param | Type | Description |
|
|
178
|
+
| --- | --- | --- |
|
|
179
|
+
| searchParams | <code>URLSearchParams</code> | the search params object |
|
|
180
|
+
|
|
181
|
+
<a name="extractBodyData"></a>
|
|
182
|
+
|
|
183
|
+
## extractBodyData(request) ⇒ <code>Object</code>
|
|
184
|
+
Extracts and parses the body data from the request
|
|
185
|
+
|
|
186
|
+
**Kind**: global function
|
|
187
|
+
**Returns**: <code>Object</code> - The body data
|
|
188
|
+
**Throws**:
|
|
189
|
+
|
|
190
|
+
- <code>Error</code> If an error occurs parsing the body
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
| Param | Type | Description |
|
|
194
|
+
| --- | --- | --- |
|
|
195
|
+
| request | [<code>PipelineRequest</code>](#PipelineRequest) | the request object (see fetch api) |
|
|
196
|
+
|
|
197
|
+
<a name="formsPipe"></a>
|
|
198
|
+
|
|
199
|
+
## formsPipe(state, request) ⇒ [<code>Promise.<PipelineResponse></code>](#PipelineResponse)
|
|
200
|
+
Handle a pipeline POST request.
|
|
201
|
+
At this point POST's only apply to json files that are backed by a workbook.
|
|
202
|
+
|
|
203
|
+
**Kind**: global function
|
|
204
|
+
**Returns**: [<code>Promise.<PipelineResponse></code>](#PipelineResponse) - a response
|
|
205
|
+
|
|
206
|
+
| Param | Type | Description |
|
|
207
|
+
| --- | --- | --- |
|
|
208
|
+
| state | [<code>PipelineState</code>](#PipelineState) | pipeline options |
|
|
209
|
+
| request | [<code>PipelineRequest</code>](#PipelineRequest) | |
|
|
210
|
+
|
|
211
|
+
<a name="htmlPipe"></a>
|
|
212
|
+
|
|
213
|
+
## htmlPipe(state, req) ⇒ [<code>PipelineResponse</code>](#PipelineResponse)
|
|
214
|
+
Runs the default pipeline and returns the response.
|
|
215
|
+
|
|
216
|
+
**Kind**: global function
|
|
217
|
+
|
|
218
|
+
| Param | Type |
|
|
219
|
+
| --- | --- |
|
|
220
|
+
| state | [<code>PipelineState</code>](#PipelineState) |
|
|
221
|
+
| req | [<code>PipelineRequest</code>](#PipelineRequest) |
|
|
222
|
+
|
|
223
|
+
<a name="htmlPipe..res"></a>
|
|
224
|
+
|
|
225
|
+
### htmlPipe~res : [<code>PipelineResponse</code>](#PipelineResponse)
|
|
226
|
+
**Kind**: inner constant of [<code>htmlPipe</code>](#htmlPipe)
|
|
227
|
+
<a name="jsonPipe"></a>
|
|
228
|
+
|
|
229
|
+
## jsonPipe(state, req) ⇒ [<code>PipelineResponse</code>](#PipelineResponse)
|
|
230
|
+
Runs the default pipeline and returns the response.
|
|
231
|
+
|
|
232
|
+
**Kind**: global function
|
|
233
|
+
|
|
234
|
+
| Param | Type |
|
|
235
|
+
| --- | --- |
|
|
236
|
+
| state | [<code>PipelineState</code>](#PipelineState) |
|
|
237
|
+
| req | [<code>PipelineRequest</code>](#PipelineRequest) |
|
|
238
|
+
|
|
239
|
+
<a name="optionsPipe"></a>
|
|
240
|
+
|
|
241
|
+
## optionsPipe(state, request) ⇒ <code>Response</code>
|
|
242
|
+
Handles options requests
|
|
5
243
|
|
|
6
244
|
**Kind**: global function
|
|
7
|
-
**Returns**: <code>
|
|
245
|
+
**Returns**: <code>Response</code> - a response
|
|
8
246
|
|
|
9
247
|
| Param | Type | Description |
|
|
10
248
|
| --- | --- | --- |
|
|
11
|
-
|
|
|
249
|
+
| state | [<code>PipelineState</code>](#PipelineState) | pipeline options |
|
|
250
|
+
| request | [<code>PipelineRequest</code>](#PipelineRequest) | |
|
|
12
251
|
|
package/package.json
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-html-pipeline",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.7",
|
|
4
4
|
"description": "Helix HTML Pipeline",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"test": " c8 mocha",
|
|
10
|
-
"test-ci": "c8 mocha && codecov",
|
|
11
10
|
"lint": "eslint .",
|
|
12
11
|
"docs": "npx jsdoc2md -c .jsdoc.json --files 'src/*.js' > docs/API.md",
|
|
13
12
|
"semantic-release": "semantic-release",
|
|
14
|
-
"commit": "git-cz",
|
|
15
13
|
"prepare": "husky install"
|
|
16
14
|
},
|
|
17
15
|
"repository": {
|
|
@@ -32,8 +30,8 @@
|
|
|
32
30
|
"loader": "esmock"
|
|
33
31
|
},
|
|
34
32
|
"dependencies": {
|
|
35
|
-
"@adobe/helix-markdown-support": "3.1.
|
|
36
|
-
"@adobe/helix-shared-utils": "2.0.
|
|
33
|
+
"@adobe/helix-markdown-support": "3.1.5",
|
|
34
|
+
"@adobe/helix-shared-utils": "2.0.10",
|
|
37
35
|
"github-slugger": "1.4.0",
|
|
38
36
|
"hast-util-raw": "7.2.1",
|
|
39
37
|
"hast-util-select": "5.0.1",
|
|
@@ -72,10 +70,6 @@
|
|
|
72
70
|
"@semantic-release/git": "10.0.1",
|
|
73
71
|
"@semantic-release/npm": "9.0.1",
|
|
74
72
|
"c8": "7.11.2",
|
|
75
|
-
"chalk-template": "0.4.0",
|
|
76
|
-
"codecov": "3.8.3",
|
|
77
|
-
"commitizen": "4.2.4",
|
|
78
|
-
"cz-conventional-changelog": "3.3.0",
|
|
79
73
|
"eslint": "8.15.0",
|
|
80
74
|
"eslint-plugin-header": "3.1.1",
|
|
81
75
|
"eslint-plugin-import": "2.26.0",
|
|
@@ -94,10 +88,5 @@
|
|
|
94
88
|
"lint-staged": {
|
|
95
89
|
"*.js": "eslint",
|
|
96
90
|
"*.cjs": "eslint"
|
|
97
|
-
},
|
|
98
|
-
"config": {
|
|
99
|
-
"commitizen": {
|
|
100
|
-
"path": "node_modules/cz-conventional-changelog"
|
|
101
|
-
}
|
|
102
91
|
}
|
|
103
92
|
}
|
package/src/PipelineContent.d.ts
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
import {Node} from "unist";
|
|
13
|
-
import GithubSlugger from 'github-slugger';
|
|
14
13
|
import { Root } from 'hast';
|
|
14
|
+
import { IDSlugger } from './utils/id-slugger.js';
|
|
15
15
|
|
|
16
16
|
declare enum SourceType {
|
|
17
17
|
CONTENT = 'content',
|
|
@@ -58,7 +58,7 @@ declare class PipelineContent {
|
|
|
58
58
|
/**
|
|
59
59
|
* slugger to use for heading id calculations
|
|
60
60
|
*/
|
|
61
|
-
slugger:
|
|
61
|
+
slugger: IDSlugger;
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* document specific metadata
|
package/src/PipelineContent.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
import
|
|
12
|
+
import { IDSlugger } from './utils/id-slugger.js';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* State of the pipeline
|
|
@@ -22,7 +22,7 @@ export class PipelineContent {
|
|
|
22
22
|
constructor() {
|
|
23
23
|
Object.assign(this, {
|
|
24
24
|
sourceBus: 'content',
|
|
25
|
-
slugger: new
|
|
25
|
+
slugger: new IDSlugger(),
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import GithubSlugger from 'github-slugger';
|
|
13
|
+
|
|
14
|
+
export class IDSlugger {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.occurrences = {};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Generate a unique slug.
|
|
21
|
+
* @param {string} value String of text to slugify
|
|
22
|
+
* @return {string} A unique slug string
|
|
23
|
+
*/
|
|
24
|
+
slug(value) {
|
|
25
|
+
let id = GithubSlugger.slug(value)
|
|
26
|
+
// remove leading numbers
|
|
27
|
+
.replace(/^\d+-+/, '');
|
|
28
|
+
|
|
29
|
+
// resolve collisions
|
|
30
|
+
const original = id;
|
|
31
|
+
while (id in this.occurrences) {
|
|
32
|
+
this.occurrences[original] += 1;
|
|
33
|
+
id = `${original}-${this.occurrences[original]}`;
|
|
34
|
+
}
|
|
35
|
+
this.occurrences[id] = 0;
|
|
36
|
+
return id;
|
|
37
|
+
}
|
|
38
|
+
}
|