@adobe/helix-md2jcr 1.0.7 → 1.0.9
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 +15 -0
- package/baseline-tests.sh +1 -1
- package/package.json +3 -3
- package/src/mdast2jcr/domain/Models.js +19 -4
- package/src/mdast2jcr/hb/helpers/page-helper.js +6 -1
- package/src/mdast2jcr/hb/helpers/section-helper.js +11 -0
- package/src/mdast2jcr/hb/partials/grid-table.js +11 -2
- package/src/mdast2jcr/hb/partials/heading.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## [1.0.9](https://github.com/adobe/helix-md2jcr/compare/v1.0.8...v1.0.9) (2025-02-04)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** update dependency @adobe/helix-shared-process-queue to v3.1.0 ([#48](https://github.com/adobe/helix-md2jcr/issues/48)) ([d779bde](https://github.com/adobe/helix-md2jcr/commit/d779bde1286fee65ee3385c891aa5309697fb9ff))
|
|
7
|
+
|
|
8
|
+
## [1.0.8](https://github.com/adobe/helix-md2jcr/compare/v1.0.7...v1.0.8) (2025-02-04)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **sites-28652:** include model fields property into the generated xml node structure ([#45](https://github.com/adobe/helix-md2jcr/issues/45)) ([7699250](https://github.com/adobe/helix-md2jcr/commit/769925099ccb7edb37544dc5767aec857297ed4a))
|
|
14
|
+
* **sites-28737:** title should use title and not jcr:title ([#47](https://github.com/adobe/helix-md2jcr/issues/47)) ([e843c08](https://github.com/adobe/helix-md2jcr/commit/e843c0876e3a40473e06b40b999977ce6bee3422))
|
|
15
|
+
|
|
1
16
|
## [1.0.7](https://github.com/adobe/helix-md2jcr/compare/v1.0.6...v1.0.7) (2025-02-03)
|
|
2
17
|
|
|
3
18
|
|
package/baseline-tests.sh
CHANGED
|
@@ -65,7 +65,7 @@ for MD_FILE in $MD_FILES; do
|
|
|
65
65
|
# if VERBOSE is true then echo a new line
|
|
66
66
|
[ "$VERBOSE" = "true" ] && echo
|
|
67
67
|
|
|
68
|
-
node "$NODE_SCRIPT" "$MD_FILE" $ARGS
|
|
68
|
+
node "$NODE_SCRIPT" "$MD_FILE" $ARGS 2>/dev/null
|
|
69
69
|
|
|
70
70
|
# Check if the Node.js script executed successfully
|
|
71
71
|
if [ $? -ne 0 ]; then
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-md2jcr",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "Helix Service that converts markdown to JCR content structure",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@adobe/fetch": "4.1.11",
|
|
32
32
|
"@adobe/helix-markdown-support": "7.1.10",
|
|
33
|
-
"@adobe/helix-shared-process-queue": "3.0
|
|
33
|
+
"@adobe/helix-shared-process-queue": "3.1.0",
|
|
34
34
|
"@adobe/remark-gridtables": "3.0.9",
|
|
35
35
|
"entities": "^5.0.0",
|
|
36
36
|
"github-slugger": "2.0.0",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@adobe/eslint-config-helix": "2.0.8",
|
|
58
|
-
"@adobe/helix-mediahandler": "2.5.
|
|
58
|
+
"@adobe/helix-mediahandler": "2.5.49",
|
|
59
59
|
"@commitlint/cli": "^19.6.1",
|
|
60
60
|
"@commitlint/config-conventional": "^19.6.0",
|
|
61
61
|
"@semantic-release/changelog": "6.0.3",
|
|
@@ -21,13 +21,14 @@
|
|
|
21
21
|
* Get the model id from the array of models.
|
|
22
22
|
* @param {Array<Model>} models The array of models.
|
|
23
23
|
* @param {string} modelId The model id.
|
|
24
|
-
* @return {Model}
|
|
24
|
+
* @return {Model|null} The model or undefined if not found.
|
|
25
25
|
*/
|
|
26
26
|
function findModelById(models, modelId) {
|
|
27
|
-
if (
|
|
28
|
-
|
|
27
|
+
if (models && Object.keys(models)?.length > 0) {
|
|
28
|
+
return models.find((model) => model.id === modelId);
|
|
29
|
+
} else {
|
|
30
|
+
return undefined;
|
|
29
31
|
}
|
|
30
|
-
return models.find((model) => model.id === modelId);
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
/**
|
|
@@ -40,7 +41,21 @@ function getField(model, fieldName) {
|
|
|
40
41
|
return model.fields.find((field) => field.name === fieldName);
|
|
41
42
|
}
|
|
42
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Return a comma-separated list of fields in the model. If no fields are found,
|
|
46
|
+
* return an empty string.
|
|
47
|
+
* @param model
|
|
48
|
+
* @return {string}
|
|
49
|
+
*/
|
|
50
|
+
function getModelFields(model) {
|
|
51
|
+
return model.fields
|
|
52
|
+
.map((f) => f.name)
|
|
53
|
+
.filter((f) => f !== 'classes')
|
|
54
|
+
.join(',');
|
|
55
|
+
}
|
|
56
|
+
|
|
43
57
|
export {
|
|
44
58
|
getField,
|
|
45
59
|
findModelById,
|
|
60
|
+
getModelFields,
|
|
46
61
|
};
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { find } from 'unist-util-find';
|
|
13
13
|
import { toString } from 'mdast-util-to-string';
|
|
14
|
-
import { findModelById, getField } from '../../domain/Models.js';
|
|
14
|
+
import { findModelById, getField, getModelFields } from '../../domain/Models.js';
|
|
15
15
|
import { findAll } from '../../utils/mdast.js';
|
|
16
16
|
import { encodeHTMLEntities, stripNewlines } from '../../utils.js';
|
|
17
17
|
import link from '../partials/supports/link.js';
|
|
@@ -66,6 +66,11 @@ function buildPageMetadata(table, models) {
|
|
|
66
66
|
mappedMetadata[mappedKey] = value;
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
+
if (model) {
|
|
70
|
+
const fields = getModelFields(model);
|
|
71
|
+
mappedMetadata.modelFields = `[${fields}]`;
|
|
72
|
+
}
|
|
73
|
+
|
|
69
74
|
return mappedMetadata;
|
|
70
75
|
}
|
|
71
76
|
|
|
@@ -13,13 +13,24 @@ import Handlebars from 'handlebars';
|
|
|
13
13
|
import { find } from 'unist-util-find';
|
|
14
14
|
import { toString } from 'mdast-util-to-string';
|
|
15
15
|
import { findAll } from '../../utils/mdast.js';
|
|
16
|
+
import { findModelById, getModelFields } from '../../domain/Models.js';
|
|
16
17
|
|
|
17
18
|
function sectionHelper(index, children, options) {
|
|
19
|
+
const {
|
|
20
|
+
models,
|
|
21
|
+
} = options.data.root;
|
|
22
|
+
|
|
18
23
|
const attributes = {
|
|
19
24
|
'sling:resourceType': 'core/franklin/components/section/v1/section',
|
|
20
25
|
'jcr:primaryType': 'nt:unstructured',
|
|
21
26
|
};
|
|
22
27
|
|
|
28
|
+
const model = findModelById(models, 'section-metadata');
|
|
29
|
+
if (model) {
|
|
30
|
+
const fields = getModelFields(model);
|
|
31
|
+
attributes.modelFields = `[${fields}]`;
|
|
32
|
+
}
|
|
33
|
+
|
|
23
34
|
const uniqueName = Handlebars.helpers.nameHelper.call(this, 'section');
|
|
24
35
|
|
|
25
36
|
// find the table that has a gtHeader that has a header value that contains 'section-metadata'
|
|
@@ -18,7 +18,7 @@ import { toHast } from 'mdast-util-to-hast';
|
|
|
18
18
|
import { toHtml } from 'hast-util-to-html';
|
|
19
19
|
import { getComponentById, getComponentByTitle, getModelId } from '../../domain/Definitions.js';
|
|
20
20
|
import {
|
|
21
|
-
findModelById, getField,
|
|
21
|
+
findModelById, getField, getModelFields,
|
|
22
22
|
} from '../../domain/Models.js';
|
|
23
23
|
import { findAll } from '../../utils/mdast.js';
|
|
24
24
|
import link from './supports/link.js';
|
|
@@ -371,8 +371,13 @@ function getBlockItems(mdast, modelHelper, definitions, allowedComponents) {
|
|
|
371
371
|
const fieldGroup = modelHelper.getModelFieldGroup(componentId);
|
|
372
372
|
if (fieldGroup) {
|
|
373
373
|
const component = getComponentById(definitions, componentId);
|
|
374
|
-
const properties = {
|
|
374
|
+
const properties = {
|
|
375
|
+
...component.defaultFields,
|
|
376
|
+
modelFields: `[${getModelFields(fieldGroup.model)}]`,
|
|
377
|
+
};
|
|
378
|
+
|
|
375
379
|
extractProperties(row, fieldGroup.model, 'blockItem', component, fieldGroup.fields, properties);
|
|
380
|
+
|
|
376
381
|
items.push(`<item_${items.length} sling:resourceType="core/franklin/components/block/v1/block/item" name="${fieldGroup.model.id}" ${Object.entries(properties).map(([k, v]) => `${k}="${v}"`).join(' ')}></item_${items.length}>`);
|
|
377
382
|
}
|
|
378
383
|
} else {
|
|
@@ -442,6 +447,10 @@ function gridTablePartial(context) {
|
|
|
442
447
|
...blockHeaderProperties,
|
|
443
448
|
};
|
|
444
449
|
|
|
450
|
+
if (model) {
|
|
451
|
+
properties.modelFields = `[${getModelFields(model)}]`;
|
|
452
|
+
}
|
|
453
|
+
|
|
445
454
|
let blockProperties = '';
|
|
446
455
|
let fieldGroup;
|
|
447
456
|
|
|
@@ -47,7 +47,7 @@ function heading(context) {
|
|
|
47
47
|
|
|
48
48
|
title = Handlebars.Utils.escapeExpression(context.children.map(parseInlineElements).join(''));
|
|
49
49
|
|
|
50
|
-
return `<title${uniqueName} sling:resourceType="core/franklin/components/title/v1/title" jcr:primaryType="nt:unstructured"
|
|
50
|
+
return `<title${uniqueName} sling:resourceType="core/franklin/components/title/v1/title" jcr:primaryType="nt:unstructured" title="${title}" type="h${depth}"/>\n`;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export default heading;
|