Skip to content

Commit 2a56192

Browse files
authored
fix(sites-29465): aem-block-collection-xwalk requires block's to have their own _<block>.json file (#11)
1 parent 79f4bbc commit 2a56192

29 files changed

+1980
-373
lines changed

Diff for: .husky/pre-commit

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node .husky/pre-commit.mjs

Diff for: .husky/pre-commit.mjs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { exec } from "node:child_process";
2+
3+
const run = (cmd) => new Promise((resolve, reject) => exec(
4+
cmd,
5+
(error, stdout) => {
6+
if (error) reject(error);
7+
else resolve(stdout);
8+
}
9+
));
10+
11+
const changeset = await run('git diff --cached --name-only --diff-filter=ACMR');
12+
const modifiedFiles = changeset.split('\n').filter(Boolean);
13+
14+
// check if there are any model files staged
15+
const modifiedPartials = modifiedFiles.filter((file) => file.match(/(^|\/)_.*.json/));
16+
if (modifiedPartials.length > 0) {
17+
const output = await run('npm run build:json --silent');
18+
console.log(output);
19+
await run('git add component-models.json component-definition.json component-filters.json');
20+
}

Diff for: blocks/accordion/_accordion.json

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"definitions": [
3+
{
4+
"title": "Accordion",
5+
"id": "accordion",
6+
"plugins": {
7+
"xwalk": {
8+
"page": {
9+
"resourceType": "core/franklin/components/block/v1/block",
10+
"template": {
11+
"name": "Accordion",
12+
"filter": "accordion"
13+
}
14+
}
15+
}
16+
}
17+
},
18+
{
19+
"title": "Accordion Item",
20+
"id": "accordion-item",
21+
"plugins": {
22+
"xwalk": {
23+
"page": {
24+
"resourceType": "core/franklin/components/block/v1/block/item",
25+
"template": {
26+
"name": "Accordion Item",
27+
"model": "accordion-item",
28+
"summary": "Lorem Ipsum",
29+
"text": "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur volutpat consequat dui, sit amet ...</p>"
30+
}
31+
}
32+
}
33+
}
34+
}
35+
],
36+
"models": [
37+
{
38+
"id": "accordion-item",
39+
"fields": [
40+
{
41+
"component": "text",
42+
"valueType": "string",
43+
"name": "summary",
44+
"value": "",
45+
"label": "Summary"
46+
},
47+
{
48+
"component": "richtext",
49+
"name": "text",
50+
"value": "",
51+
"label": "Text",
52+
"valueType": "string"
53+
}
54+
]
55+
}
56+
],
57+
"filters": [
58+
{
59+
"id": "accordion",
60+
"components": ["accordion-item"]
61+
}
62+
]
63+
}

Diff for: blocks/cards/_cards.json

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"definitions": [
3+
{
4+
"title": "Cards",
5+
"id": "cards",
6+
"plugins": {
7+
"xwalk": {
8+
"page": {
9+
"resourceType": "core/franklin/components/block/v1/block",
10+
"template": {
11+
"name": "Cards",
12+
"filter": "cards"
13+
}
14+
}
15+
}
16+
}
17+
},
18+
{
19+
"title": "Card",
20+
"id": "card",
21+
"plugins": {
22+
"xwalk": {
23+
"page": {
24+
"resourceType": "core/franklin/components/block/v1/block/item",
25+
"template": {
26+
"name": "Card",
27+
"model": "card"
28+
}
29+
}
30+
}
31+
}
32+
}
33+
],
34+
"models": [
35+
{
36+
"id": "card",
37+
"fields": [
38+
{
39+
"component": "reference",
40+
"valueType": "string",
41+
"name": "image",
42+
"label": "Image",
43+
"multi": false
44+
},
45+
{
46+
"component": "richtext",
47+
"name": "text",
48+
"value": "",
49+
"label": "Text",
50+
"valueType": "string"
51+
}
52+
]
53+
}
54+
],
55+
"filters": [
56+
{
57+
"id": "cards",
58+
"components": ["card"]
59+
}
60+
]
61+
}

Diff for: blocks/carousel/_carousel.json

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"definitions": [
3+
{
4+
"title": "Carousel",
5+
"id": "carousel",
6+
"plugins": {
7+
"xwalk": {
8+
"page": {
9+
"resourceType": "core/franklin/components/block/v1/block",
10+
"template": {
11+
"name": "Carousel",
12+
"model": "carousel",
13+
"filter": "carousel"
14+
}
15+
}
16+
}
17+
}
18+
},
19+
{
20+
"title": "Carousel Slide",
21+
"id": "carousel-item",
22+
"plugins": {
23+
"xwalk": {
24+
"page": {
25+
"resourceType": "core/franklin/components/block/v1/block/item",
26+
"template": {
27+
"name": "Carousel Slide",
28+
"model": "carousel-item"
29+
}
30+
}
31+
}
32+
}
33+
}
34+
],
35+
"models": [
36+
{
37+
"id": "carousel-item",
38+
"fields": [
39+
{
40+
"component": "reference",
41+
"valueType": "string",
42+
"name": "media_image",
43+
"label": "Background Image",
44+
"multi": false
45+
},
46+
{
47+
"component": "text",
48+
"valueType": "string",
49+
"name": "media_imageAlt",
50+
"value": "",
51+
"label": "Bacgkround Alt"
52+
},
53+
{
54+
"component": "richtext",
55+
"name": "content_text",
56+
"value": "",
57+
"label": "Text",
58+
"valueType": "string"
59+
}
60+
]
61+
}
62+
],
63+
"filters": [
64+
{
65+
"id": "carousel",
66+
"components": ["carousel-item"]
67+
}
68+
]
69+
}

Diff for: blocks/columns/_columns.json

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"definitions": [
3+
{
4+
"title": "Columns",
5+
"id": "columns",
6+
"plugins": {
7+
"xwalk": {
8+
"page": {
9+
"resourceType": "core/franklin/components/columns/v1/columns",
10+
"template": {
11+
"columns": "2",
12+
"rows": "1"
13+
}
14+
}
15+
}
16+
}
17+
}
18+
],
19+
"models": [
20+
{
21+
"id": "columns",
22+
"fields": [
23+
{
24+
"component": "text",
25+
"valueType": "number",
26+
"name": "columns",
27+
"value": "",
28+
"label": "Columns"
29+
},
30+
{
31+
"component": "text",
32+
"valueType": "number",
33+
"name": "rows",
34+
"value": "",
35+
"label": "Rows"
36+
}
37+
]
38+
}
39+
],
40+
"filters": [
41+
{
42+
"id": "columns",
43+
"components": ["column"]
44+
},
45+
{
46+
"id": "column",
47+
"components": ["text", "image", "button", "title"]
48+
}
49+
]
50+
}

Diff for: blocks/embed/_embed.json

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"definitions": [
3+
{
4+
"title": "Embed",
5+
"id": "embed",
6+
"plugins": {
7+
"xwalk": {
8+
"page": {
9+
"resourceType": "core/franklin/components/block/v1/block",
10+
"template": {
11+
"name": "Embed",
12+
"model": "embed",
13+
"filter": "embed"
14+
}
15+
}
16+
}
17+
}
18+
}
19+
],
20+
"models": [
21+
{
22+
"id": "embed",
23+
"fields": [
24+
{
25+
"component": "reference",
26+
"valueType": "string",
27+
"name": "embed_placeholder",
28+
"label": "Placeholder Image",
29+
"multi": false
30+
},
31+
{
32+
"component": "text",
33+
"valueType": "string",
34+
"name": "embed_placeholderAlt",
35+
"value": "",
36+
"label": "Placeholder Image Alt Text"
37+
},
38+
{
39+
"component": "text",
40+
"valueType": "string",
41+
"name": "embed_uri",
42+
"label": "URI"
43+
}
44+
]
45+
}
46+
],
47+
"filters": []
48+
}

Diff for: blocks/fragment/_fragment.json

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"definitions": [
3+
{
4+
"title": "Fragment",
5+
"id": "fragment",
6+
"plugins": {
7+
"xwalk": {
8+
"page": {
9+
"resourceType": "core/franklin/components/block/v1/block",
10+
"template": {
11+
"name": "Fragment",
12+
"model": "fragment"
13+
}
14+
}
15+
}
16+
}
17+
}
18+
],
19+
"models": [
20+
{
21+
"id": "fragment",
22+
"fields": [
23+
{
24+
"component": "aem-content",
25+
"name": "reference",
26+
"label": "Reference"
27+
}
28+
]
29+
}
30+
],
31+
"filters": []
32+
}

0 commit comments

Comments
 (0)