feat: add editorial query blocks

This commit is contained in:
chrnx committed 2026-08-11 15:27:44 -05:00
1 parent 835fb74ebf
commit 89dcc53e02
24 files changed
+1421

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "chrnx/featured-stories",
"version": "0.1.0",
"title": "Featured Stories",
"category": "theme",
"description": "A sticky-led selection of topic-diverse stories.",
"textdomain": "chrnx",
"attributes": {
"limit": { "type": "integer", "default": 3, "minimum": 1, "maximum": 12 },
"headingLevel": { "type": "integer", "default": 2, "enum": [2, 3, 4, 5, 6] }
},
"supports": { "html": false, "align": ["wide", "full"] },
"style": "file:./style.css",
"render": "file:./render.php"
}
+23
View File
@@ -0,0 +1,23 @@
<?php
/**
* Featured Stories block render.
*
* @package CHRNX
*/
$chrnx_limit = isset( $attributes['limit'] ) ? min( 12, max( 1, absint( $attributes['limit'] ) ) ) : 3;
$chrnx_heading = chrnx_get_heading_level( $attributes['headingLevel'] ?? 2, 2 );
$chrnx_ids = chrnx_get_featured_story_ids( $chrnx_limit );
if ( empty( $chrnx_ids ) ) {
return;
}
?>
<section <?php echo get_block_wrapper_attributes( array( 'class' => 'chrnx-featured-stories' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> aria-label="<?php echo esc_attr__( 'Featured stories', 'chrnx' ); ?>">
<div class="chrnx-featured-stories__grid">
<?php
foreach ( $chrnx_ids as $chrnx_post_id ) {
echo chrnx_get_editorial_card_markup( $chrnx_post_id, $chrnx_heading, 'chrnx-featured-story' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
?>
</div>
</section>
+27
View File
@@ -0,0 +1,27 @@
.chrnx-featured-stories__grid {
display: grid;
gap: var(--wp--preset--spacing--40, 1.5rem);
grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
}
.chrnx-featured-story,
.chrnx-featured-story__link {
height: 100%;
}
.chrnx-featured-story__link {
display: flex;
flex-direction: column;
}
.chrnx-featured-story__image,
.chrnx-featured-story__fallback {
aspect-ratio: 3 / 2;
display: block;
object-fit: cover;
width: 100%;
}
.chrnx-featured-story__fallback {
background: linear-gradient(135deg, var(--wp--preset--color--violet), var(--wp--preset--color--green));
}