Skip to content

Commit ac31033

Browse files
committed
update shared block attributes
1 parent 3f7bfc2 commit ac31033

File tree

3 files changed

+65
-114
lines changed

3 files changed

+65
-114
lines changed

schemas/theme/section.json

Lines changed: 31 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@
112112
},
113113
"blocks": {
114114
"oneOf": [
115-
{ "$ref": "#/definitions/blocks_array" },
116-
{ "$ref": "#/definitions/blocks_hash" }
115+
{ "$ref": "#/definitions/blocksArray" },
116+
{ "$ref": "#/definitions/blocksHash" }
117117
]
118118
}
119119
}
@@ -221,61 +221,46 @@
221221
}
222222
}
223223
},
224-
"blocks_array": {
224+
"blocksArray": {
225225
"type": "array",
226226
"description": "A list of child blocks that you might want to include.",
227-
"markdownDescription": "A list of child blocks that you might want to include.\n\n---\n\n[Shopify reference](https://shopify.dev/docs/themes/architecture/blocks/theme-blocks/schema#presets)",
228-
"required": ["type"],
227+
"markdownDescription": "A list of child blocks that you might want to include.\n\n---\n\n[Shopify reference](https://shopify.dev/docs/themes/architecture/sections/section-schema#presets)",
229228
"items": {
230229
"type": "object",
231230
"properties": {
232-
"$ref": "#/definitions/base_block",
233-
"id": {
234-
"type": "string"
235-
}
236-
},
237-
"allOf": [
238-
{
239-
"if": {
240-
"properties": {
241-
"static": {
242-
"const": true
243-
}
244-
},
245-
"required": ["static"]
246-
},
247-
"then": {
248-
"required": ["id"]
231+
"type": "object",
232+
"allOf": [{ "$ref": "#/definitions/commonBlockAttributes" }],
233+
"properties": {
234+
"static": true,
235+
"type": true,
236+
"settings": true,
237+
"blocks": true,
238+
"id": {
239+
"type": "string",
240+
"description": "A unique identifier for the block."
249241
}
250-
}
251-
]
242+
},
243+
"additionalProperties": false
244+
},
245+
"if": {
246+
"properties": {
247+
"static": { "const": true }
248+
},
249+
"required": ["static"]
250+
},
251+
"then": {
252+
"required": ["id"]
253+
}
252254
}
253255
},
254-
"blocks_hash": {
256+
"blocksHash": {
255257
"type": "object",
256258
"description": "A list of child blocks that you might want to include.",
257-
"markdownDescription": "A list of child blocks that you might want to include.\n\n---\n\n[Shopify reference](https://shopify.dev/docs/themes/architecture/blocks/theme-blocks/schema#presets)",
259+
"markdownDescription": "A list of child blocks that you might want to include.\n\n---\n\n[Shopify reference](https://shopify.dev/docs/themes/architecture/sections/section-schema#presets)",
258260
"additionalProperties": {
259-
"$ref": "#/definitions/base_block"
260-
}
261-
},
262-
"base_block": {
263-
"type": "object",
264-
"required": ["type"],
265-
"properties": {
266-
"type": {
267-
"type": "string",
268-
"description": "The block type."
269-
},
270-
"settings": {
271-
"$ref": "./default_setting_values.json"
272-
},
273-
"blocks": {
274-
"$ref": "#/properties/presets/items/properties/blocks"
275-
},
276-
"static": {
277-
"type": "boolean",
278-
"description": "If the block is rendered statically or not"
261+
"type": "object",
262+
"properties": {
263+
"$ref": "./theme_block.json#/definitions/commonBlockAttributes"
279264
}
280265
}
281266
}

schemas/theme/theme_block.json

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@
7373
},
7474
"blocks": {
7575
"oneOf": [
76-
{ "$ref": "#/definitions/blocks_array" },
77-
{ "$ref": "#/definitions/blocks_hash" }
76+
{ "$ref": "#/definitions/blocksArray" },
77+
{ "$ref": "#/definitions/blocksHash" }
7878
]
7979
}
8080
}
@@ -106,45 +106,50 @@
106106
}
107107
},
108108
"definitions": {
109-
"blocks_array": {
109+
"blocksArray": {
110110
"type": "array",
111111
"description": "A list of child blocks that you might want to include.",
112112
"markdownDescription": "A list of child blocks that you might want to include.\n\n---\n\n[Shopify reference](https://shopify.dev/docs/themes/architecture/blocks/theme-blocks/schema#presets)",
113-
"required": ["type"],
114113
"items": {
115114
"type": "object",
116115
"properties": {
117-
"$ref": "#/definitions/base_block",
118-
"id": {
119-
"type": "string"
120-
}
121-
},
122-
"allOf": [
123-
{
124-
"if": {
125-
"properties": {
126-
"static": {
127-
"const": true
128-
}
129-
},
130-
"required": ["static"]
131-
},
132-
"then": {
133-
"required": ["id"]
116+
"type": "object",
117+
"allOf": [{ "$ref": "#/definitions/commonBlockAttributes" }],
118+
"properties": {
119+
"static": true,
120+
"type": true,
121+
"settings": true,
122+
"blocks": true,
123+
"id": {
124+
"type": "string",
125+
"description": "A unique identifier for the block."
134126
}
135-
}
136-
]
127+
},
128+
"additionalProperties": false
129+
},
130+
"if": {
131+
"properties": {
132+
"static": { "const": true }
133+
},
134+
"required": ["static"]
135+
},
136+
"then": {
137+
"required": ["id"]
138+
}
137139
}
138140
},
139-
"blocks_hash": {
141+
"blocksHash": {
140142
"type": "object",
141143
"description": "A list of child blocks that you might want to include.",
142144
"markdownDescription": "A list of child blocks that you might want to include.\n\n---\n\n[Shopify reference](https://shopify.dev/docs/themes/architecture/blocks/theme-blocks/schema#presets)",
143-
"additionalProperties": {
144-
"$ref": "#/definitions/base_block"
145-
}
145+
"patternProperties": {
146+
"^[a-zA-Z0-9_-]+$": {
147+
"allOf": [{ "$ref": "#/definitions/commonBlockAttributes" }]
148+
}
149+
},
150+
"additionalProperties": false
146151
},
147-
"base_block": {
152+
"commonBlockAttributes": {
148153
"type": "object",
149154
"required": ["type"],
150155
"properties": {
@@ -160,7 +165,7 @@
160165
},
161166
"static": {
162167
"type": "boolean",
163-
"description": "If the block is rendered statically or not"
168+
"description": "If the block is rendered statically or not."
164169
}
165170
}
166171
}

tests/fixtures/theme-blocks-presets-as-hash.json

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)