Refine homepage shortcode layout and rendering cleanup
This commit is contained in:
@@ -399,6 +399,13 @@ class AdminController
|
||||
'source' => 'Pages module',
|
||||
'enabled' => true,
|
||||
],
|
||||
[
|
||||
'tag' => '[home-catalog]',
|
||||
'description' => 'Complete homepage catalog block (hero + releases + chart + artists + newsletter).',
|
||||
'example' => '[home-catalog release_limit="8" artist_limit="6" chart_limit="10"]',
|
||||
'source' => 'Pages module',
|
||||
'enabled' => true,
|
||||
],
|
||||
[
|
||||
'tag' => '[login-link]',
|
||||
'description' => 'Renders an account login link.',
|
||||
@@ -503,6 +510,7 @@ class AdminController
|
||||
'sale-chart',
|
||||
'top-sellers',
|
||||
'hero',
|
||||
'home-catalog',
|
||||
'login-link',
|
||||
'account-link',
|
||||
'cart-link',
|
||||
@@ -565,6 +573,10 @@ class AdminController
|
||||
. '.ac-shortcode-newsletter-row{display:grid;grid-template-columns:1fr auto;gap:8px;}'
|
||||
. '.ac-shortcode-newsletter-input{height:40px;border:1px solid rgba(255,255,255,.16);border-radius:10px;background:rgba(8,10,16,.6);color:#f5f7ff;padding:0 12px;font-size:14px;}'
|
||||
. '.ac-shortcode-newsletter-btn{height:40px;padding:0 14px;border:1px solid rgba(57,244,179,.6);border-radius:999px;background:rgba(57,244,179,.16);color:#9ff8d8;font-size:12px;letter-spacing:.14em;text-transform:uppercase;font-family:"IBM Plex Mono",monospace;cursor:pointer;}'
|
||||
. '.ac-home-catalog{display:grid;gap:14px;}'
|
||||
. '.ac-home-columns{display:grid;grid-template-columns:minmax(0,2.2fr) minmax(280px,1fr);gap:14px;align-items:start;}'
|
||||
. '.ac-home-main,.ac-home-side{display:grid;gap:14px;align-content:start;}'
|
||||
. '@media (max-width:1200px){.ac-home-columns{grid-template-columns:1fr;}}'
|
||||
. '</style></head><body>'
|
||||
. '<div class="preview-shell"><div class="preview-head">' . htmlspecialchars($code, ENT_QUOTES, 'UTF-8') . '</div>'
|
||||
. $rendered
|
||||
|
||||
@@ -39,12 +39,22 @@ class PagesController
|
||||
return $this->notFound();
|
||||
}
|
||||
|
||||
$rendered = Shortcodes::render((string)$page['content_html'], [
|
||||
'page_slug' => $slug,
|
||||
'page_title' => (string)$page['title'],
|
||||
]);
|
||||
// WYSIWYG editors often wrap shortcode blocks in <p>, which breaks grid placement.
|
||||
$rendered = preg_replace(
|
||||
'~<p>\s*(<(?:section|div|form|a)[^>]*class="[^"]*ac-shortcode[^"]*"[^>]*>.*?</(?:section|div|form|a)>)\s*</p>~is',
|
||||
'$1',
|
||||
$rendered
|
||||
) ?? $rendered;
|
||||
$rendered = preg_replace('~(<(?:section|div|form|a)[^>]*class="[^"]*ac-shortcode[^"]*"[^>]*>)\s*<br\s*/?>~i', '$1', $rendered) ?? $rendered;
|
||||
$rendered = preg_replace('~<br\s*/?>\s*(</(?:section|div|form|a)>)~i', '$1', $rendered) ?? $rendered;
|
||||
|
||||
return new Response($this->view->render('site/show.php', [
|
||||
'title' => (string)$page['title'],
|
||||
'content_html' => Shortcodes::render((string)$page['content_html'], [
|
||||
'page_slug' => $slug,
|
||||
'page_title' => (string)$page['title'],
|
||||
]),
|
||||
'content_html' => $rendered,
|
||||
]));
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,26 @@ Shortcodes::register('hero', static function (array $attrs = []): string {
|
||||
return $html;
|
||||
});
|
||||
|
||||
Shortcodes::register('home-catalog', static function (array $attrs = []): string {
|
||||
$releaseLimit = max(1, min(12, (int)($attrs['release_limit'] ?? 8)));
|
||||
$artistLimit = max(1, min(10, (int)($attrs['artist_limit'] ?? 6)));
|
||||
$chartLimit = max(1, min(20, (int)($attrs['chart_limit'] ?? 10)));
|
||||
|
||||
$hero = Shortcodes::render('[hero eyebrow="Catalog Focus" title="Latest Drops" subtitle="Fresh releases, artists, and best sellers." cta_text="Browse Releases" cta_url="/releases" secondary_text="Meet Artists" secondary_url="/artists"]');
|
||||
$releases = Shortcodes::render('[latest-releases limit="' . $releaseLimit . '"]');
|
||||
$artists = Shortcodes::render('[new-artists limit="' . $artistLimit . '"]');
|
||||
$chart = Shortcodes::render('[sale-chart type="tracks" window="latest" limit="' . $chartLimit . '"]');
|
||||
$newsletter = Shortcodes::render('[newsletter-signup title="Join the list" button="Subscribe"]');
|
||||
|
||||
return '<section class="ac-home-catalog">'
|
||||
. $hero
|
||||
. '<div class="ac-home-columns">'
|
||||
. '<div class="ac-home-main">' . $releases . $chart . '</div>'
|
||||
. '<aside class="ac-home-side">' . $artists . $newsletter . '</aside>'
|
||||
. '</div>'
|
||||
. '</section>';
|
||||
});
|
||||
|
||||
return function (Router $router): void {
|
||||
$controller = new PagesController();
|
||||
$router->get('/page', [$controller, 'show']);
|
||||
|
||||
@@ -4,7 +4,7 @@ $contentHtml = $content_html ?? '';
|
||||
ob_start();
|
||||
?>
|
||||
<section class="card">
|
||||
<div class="page-content" style="margin-top:14px; color:var(--muted); line-height:1.8;">
|
||||
<div class="page-content" style="margin-top:14px; color:var(--muted);">
|
||||
<?= $contentHtml ?>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user