Jake Vanderwerf
2026-02-14 85f32c02f80286094cc5230a30cd7ebbe77eae2d
blocks/_setup.php
@@ -1,5 +1,4 @@
<?php
use JVBase\utility\Image;
function ajv_render_core_site_logo(array $block, string $content):string
{
@@ -13,23 +12,60 @@
    return $open.$icons.$close;
}
function ajv_render_core_cover(array $block, string $content):string
function ajv_render_core_cover(array $block):string
{
    $types = array_map(function($type) {
        return BASE.$type;
    }, array_keys(JVB_CONTENT));
    if (!is_post_type_archive($types)) {
        return JVB()->blocks()->render_core_cover($block);
    }
    $obj = get_queried_object();
    foreach ($types as $type) {
        if ($type === $obj->name) {
            $type = jvbNoBase($type);
            $function = 'ajv_render_'.$type.'_cover';
            return '<section class="align-full cover alt '.$type.'">'.call_user_func($function).'</section>';
    if (is_post_type_archive($types)) {
        $obj = get_queried_object();
        foreach ($types as $type) {
            if ($type === $obj->name) {
                $type = jvbNoBase($type);
                $function = 'ajv_render_'.$type.'_cover';
                return '<section class="align-full cover alt '.$type.'">'.call_user_func($function).'</section>';
            }
        }
    }
    return JVB()->blocks()->render_core_cover($block);
    if(!is_singular(array_map(function($item) { return BASE.$item; }, array_keys(JVB_CONTENT)))) {
        return JVB()->blocks()->render_core_cover($block);
    }
    $ID = get_the_ID();
    $imgID = get_post_thumbnail_id($ID);
    $img = '';
    if ($imgID && $imgID > 0) {
        $img = str_replace('<img', '<img style="object-fit:center"',jvbFormatImage($imgID, 'tiny', 'large', false)) ;
    }
    $post_type = jvbNoBase(get_post_type());
    $singular = JVB_CONTENT[$post_type]['singular'];
    $header = 'Canadian made '.$singular.'.&emsp;Made in Edmonton.';
    $title = get_the_title();
    $title = '<small>'.$header.'</small>'.$title;
    $date = '<small><time datetime="'.get_the_date('c').'" itemprop="datePublished">'.get_the_date().'</time></small>';
    return sprintf(
        '<section class="overlay-50 a-end end align-full cover row" style="background-color: rgba(var(--base-rgb), var(--rgb-medium));">
        %s
        <div class="content">
        <h1>%s</h1>
        %s
        </div>
        </section>',
        $img,
        $title,
        $date
    );
}
function ajv_get_limited_posts(string $type, int $limit):array {