-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix rendering and building the first block, T-25856
- Loading branch information
1 parent
68a5d0e
commit 16ed61f
Showing
28 changed files
with
13,650 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ sass/navigation/_luxbar.scss | |
html | ||
w3cErrors/ | ||
.vscode | ||
blocks/*/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.wp-block-create-block-latest-articles{border:1px dotted red} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-data', 'wp-i18n'), 'version' => '76cefaef40ac70803a1a'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.wp-block-create-block-latest-articles{border:1px dotted red} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php return array('dependencies' => array(), 'version' => '56793e2317042ba5186a'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log("Hello World! (from create-block-latest-articles block)"); |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "latest-articles", | ||
"version": "1.0.0", | ||
"scripts": { | ||
"build": "wp-scripts build", | ||
"start": "wp-scripts start" | ||
}, | ||
"devDependencies": { | ||
"@wordpress/scripts": "^30.11.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"$schema": "https://schemas.wp.org/trunk/block.json", | ||
"apiVersion": 3, | ||
"name": "air-light/latest-articles", | ||
"version": "1.0.0", | ||
"title": "Uusimmat ohjeet", | ||
"category": "air-light", | ||
"icon": "grid-view", | ||
"description": "Show latest articles in a grid.", | ||
"example": {}, | ||
"supports": { | ||
"html": false, | ||
"align": false | ||
}, | ||
"textdomain": "air-light", | ||
"editorScript": "file:./index.js", | ||
"editorStyle": "file:./index.css", | ||
"style": "file:./style-index.css", | ||
"render": "file:./render.php", | ||
"viewScript": "file:./view.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
/** | ||
* Render the latest articles block. | ||
* | ||
* @see https://github.com/WordPress/gutenberg/blob/trunk/docs/reference-guides/block-api/block-metadata.md#render | ||
* @package air-light | ||
*/ | ||
|
||
$args = [ | ||
'post_type' => 'post', | ||
'posts_per_page' => 3, | ||
'orderby' => 'date', | ||
'order' => 'DESC', | ||
]; | ||
|
||
$latest_posts = new WP_Query( $args ); | ||
|
||
if ( $latest_posts->have_posts() ) : ?> | ||
<div <?php echo get_block_wrapper_attributes( ['class' => 'latest-articles'] ); // phpcs:ignore ?>> | ||
<?php while ( $latest_posts->have_posts() ) : | ||
$latest_posts->the_post(); ?> | ||
<article class="latest-article"> | ||
<h3> | ||
<a href="<?php echo esc_url( get_permalink() ); ?>"> | ||
<?php the_title(); ?> | ||
</a> | ||
</h3> | ||
|
||
<time datetime="<?php echo get_the_date( 'c' ); ?>"> | ||
<?php echo get_the_date(); ?> | ||
</time> | ||
|
||
<div class="excerpt"> | ||
<?php the_excerpt(); ?> | ||
</div> | ||
</article> | ||
<?php endwhile; ?> | ||
</div> | ||
<?php | ||
wp_reset_postdata(); | ||
endif; |
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,6 +159,7 @@ | |
'core/textColumns', | ||
], | ||
'page' => [ | ||
// Demo blocks | ||
'air-light/latest-articles', | ||
], | ||
// 'page' => [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const { exec } = require('child_process'); | ||
const { watch } = require('gulp'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
// Build all blocks using wp-scripts | ||
function buildBlocks(done) { | ||
// Get all block directories | ||
const blocksDir = path.join(process.cwd(), 'blocks'); | ||
const blockFolders = fs.readdirSync(blocksDir) | ||
.filter(file => fs.statSync(path.join(blocksDir, file)).isDirectory()); | ||
|
||
// Build each block that has package.json | ||
const builds = blockFolders.map(blockName => { | ||
const blockPath = path.join(blocksDir, blockName); | ||
if (fs.existsSync(path.join(blockPath, 'package.json'))) { | ||
return new Promise((resolve, reject) => { | ||
exec('npm run build', { cwd: blockPath }, (err, stdout, stderr) => { | ||
if (err) { | ||
console.error(`Error building block ${blockName}:`, err); | ||
reject(err); | ||
} | ||
console.log(stdout); | ||
console.error(stderr); | ||
resolve(); | ||
}); | ||
}); | ||
} | ||
return Promise.resolve(); | ||
}); | ||
|
||
Promise.all(builds) | ||
.then(() => done()) | ||
.catch(err => done(err)); | ||
} | ||
|
||
// Watch blocks | ||
function watchBlocks() { | ||
watch([ | ||
'blocks/*/src/**/*.js', | ||
'blocks/*/src/**/*.scss', | ||
'blocks/*/*.json' | ||
], buildBlocks); | ||
} | ||
|
||
exports.buildBlocks = buildBlocks; | ||
exports.watchBlocks = watchBlocks; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters