Explorar o código

Quadrat: Change the name of the front page template (#4238)

* Quadrat: Change the name of the front page template

* Add template to theme.json

* merge customTemplates rather than overwriting

* Update the build script
Ben Dwyer %!s(int64=4) %!d(string=hai) anos
pai
achega
e0aba681d0

+ 15 - 2
blockbase/build.js

@@ -7,8 +7,20 @@ const parentThemeJsonFileName = __dirname + '/theme.json';
 const childThemeJsonFileName =
 	__dirname + '/../' + childThemeName + '/child-theme.json';
 
-const overwriteMerge = ( destinationArray, sourceArray, options ) =>
-	sourceArray;
+const keysToMerge = [ 'customTemplates' ];
+
+const overwriteMerge = ( destinationArray, sourceArray, options ) => {
+	return sourceArray;
+};
+
+const combineMerge = ( destinationArray, sourceArray, options ) =>
+	destinationArray.concat( sourceArray );
+
+const combineCustomTemplates = ( key ) => {
+	if ( keysToMerge.indexOf( key ) > -1 ) {
+		return combineMerge;
+	}
+};
 
 const buildChildTheme = () => {
 	try {
@@ -23,6 +35,7 @@ const buildChildTheme = () => {
 			parentThemeJson = JSON.parse( parentThemeJsonFile ),
 			childThemeJson = JSON.parse( childThemeJsonFile ),
 			mergedThemeJson = merge( parentThemeJson, childThemeJson, {
+				customMerge: combineCustomTemplates,
 				arrayMerge: overwriteMerge,
 			} );
 

+ 0 - 0
quadrat/block-templates/front-page.html → quadrat/block-templates/page-without-title.html


+ 10 - 0
quadrat/child-theme.json

@@ -1,4 +1,14 @@
 {
+	"customTemplates": [
+		{
+			"name": "page-without-title",
+			"title": "Page without title",
+			"postTypes": [
+				"page",
+				"post"
+			]
+		}
+	],
 	"settings": {
 		"color": {
 			"gradients": [],

+ 8 - 0
quadrat/theme.json

@@ -26,6 +26,14 @@
 				"page",
 				"post"
 			]
+		},
+		{
+			"name": "page-without-title",
+			"title": "Page without title",
+			"postTypes": [
+				"page",
+				"post"
+			]
 		}
 	],
 	"settings": {