Shortcodes: add home blocks and global custom CSS setting
This commit is contained in:
@@ -2,10 +2,37 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
use Core\Http\Router;
|
||||
use Core\Services\Shortcodes;
|
||||
use Modules\Pages\PagesController;
|
||||
|
||||
require_once __DIR__ . '/PagesController.php';
|
||||
|
||||
Shortcodes::register('hero', static function (array $attrs = []): string {
|
||||
$eyebrow = trim((string)($attrs['eyebrow'] ?? 'Catalog Focus'));
|
||||
$title = trim((string)($attrs['title'] ?? 'Latest Drops'));
|
||||
$subtitle = trim((string)($attrs['subtitle'] ?? 'Discover fresh releases, artists, and top-selling tracks.'));
|
||||
$ctaText = trim((string)($attrs['cta_text'] ?? 'Browse Releases'));
|
||||
$ctaUrl = trim((string)($attrs['cta_url'] ?? '/releases'));
|
||||
$secondaryText = trim((string)($attrs['secondary_text'] ?? 'Meet the Roster'));
|
||||
$secondaryUrl = trim((string)($attrs['secondary_url'] ?? '/artists'));
|
||||
|
||||
$html = '<section class="ac-shortcode-hero">';
|
||||
if ($eyebrow !== '') {
|
||||
$html .= '<div class="ac-shortcode-hero-eyebrow">' . htmlspecialchars($eyebrow, ENT_QUOTES, 'UTF-8') . '</div>';
|
||||
}
|
||||
$html .= '<h2 class="ac-shortcode-hero-title">' . htmlspecialchars($title, ENT_QUOTES, 'UTF-8') . '</h2>';
|
||||
if ($subtitle !== '') {
|
||||
$html .= '<p class="ac-shortcode-hero-subtitle">' . htmlspecialchars($subtitle, ENT_QUOTES, 'UTF-8') . '</p>';
|
||||
}
|
||||
$html .= '<div class="ac-shortcode-hero-actions">'
|
||||
. '<a class="ac-shortcode-hero-btn primary" href="' . htmlspecialchars($ctaUrl, ENT_QUOTES, 'UTF-8') . '">' . htmlspecialchars($ctaText, ENT_QUOTES, 'UTF-8') . '</a>';
|
||||
if ($secondaryText !== '' && $secondaryUrl !== '') {
|
||||
$html .= '<a class="ac-shortcode-hero-btn" href="' . htmlspecialchars($secondaryUrl, ENT_QUOTES, 'UTF-8') . '">' . htmlspecialchars($secondaryText, ENT_QUOTES, 'UTF-8') . '</a>';
|
||||
}
|
||||
$html .= '</div></section>';
|
||||
return $html;
|
||||
});
|
||||
|
||||
return function (Router $router): void {
|
||||
$controller = new PagesController();
|
||||
$router->get('/page', [$controller, 'show']);
|
||||
|
||||
Reference in New Issue
Block a user