feat(frontend): institutional category pages match news hub layout (BIT-623)
Align andebol.net-style category and archive routes with the /noticias editorial pattern: gradient masthead, lead article plus two-column grid, optional most-read sidebar from bridge trending, and hub pagination styling. Non-institutional themes keep the previous simple grid and header. Made-with: Cursor
This commit is contained in:
1 parent
5999fc56cc
commit
fa64f29445
1 file changed
+348
-27
@@ -5,6 +5,7 @@ import { getThemeComponents } from '../../lib/theme.js';
|
||||
import { BridgeClient, MockBridgeClient, bridgeRequestHeaders } from '../../lib/bridge.js';
|
||||
import { getUiStrings } from '../../lib/ui-i18n.js';
|
||||
import { getPublicOrigin } from '../../lib/public-origin.js';
|
||||
import { truncate } from '../../lib/format.js';
|
||||
|
||||
const { slug } = Astro.params;
|
||||
if (!slug) return Astro.redirect('/');
|
||||
@@ -53,13 +54,26 @@ try {
|
||||
return Astro.redirect('/');
|
||||
}
|
||||
|
||||
let trending: Awaited<ReturnType<BridgeClient['getTrending']>> = [];
|
||||
const is_institutional = config.theme === 'institutional';
|
||||
if (is_institutional) {
|
||||
try {
|
||||
trending = await bridge.getTrending(6);
|
||||
} catch {
|
||||
trending = [];
|
||||
}
|
||||
}
|
||||
|
||||
const cat_config = config.categories.find(c => c.slug === slug);
|
||||
const display_name = is_all_archive ? ui_early.all_news_title : (cat_config?.label ?? category.name);
|
||||
const ui = ui_early;
|
||||
const is_institutional = config.theme === 'institutional';
|
||||
const article_count_label =
|
||||
paginated.total === 1 ? `1 ${ui.article_one}` : `${paginated.total} ${ui.articles_many}`;
|
||||
|
||||
/** Eurohandball-style hub: first item as lead, rest in grid; optional sidebar */
|
||||
const lead = is_institutional && paginated.items.length > 0 ? paginated.items[0] : null;
|
||||
const grid_items = is_institutional && lead ? paginated.items.slice(1) : paginated.items;
|
||||
|
||||
const total_pages = paginated.total_pages;
|
||||
const has_prev = page > 1;
|
||||
const has_next = page < total_pages;
|
||||
@@ -83,6 +97,20 @@ const breadcrumb_schema = {
|
||||
canonical={canonical}
|
||||
schema={breadcrumb_schema}
|
||||
>
|
||||
{is_institutional && (
|
||||
<header class="cat-hub-masthead" aria-labelledby="cat-hub-masthead-title">
|
||||
<div class="container cat-page-wide">
|
||||
<p class="cat-hub-masthead__eyebrow">{config.site_name}</p>
|
||||
<h1 class="cat-hub-masthead__title" id="cat-hub-masthead-title">
|
||||
{display_name}
|
||||
</h1>
|
||||
<p class="cat-hub-masthead__sub">
|
||||
{category.description || config.tagline}
|
||||
</p>
|
||||
</div>
|
||||
</header>
|
||||
)}
|
||||
|
||||
<div class:list={['container', is_institutional && 'cat-page-wide']}>
|
||||
<!-- Breadcrumb -->
|
||||
<nav class="breadcrumb" style="padding-top: 1.5rem" aria-label="Breadcrumb">
|
||||
@@ -123,38 +151,95 @@ const breadcrumb_schema = {
|
||||
</nav>
|
||||
)}
|
||||
|
||||
<!-- Page header -->
|
||||
<header class="category-header">
|
||||
<h1 class="category-header__title">{display_name}</h1>
|
||||
{category.description && (
|
||||
<p class="category-header__desc">{category.description}</p>
|
||||
)}
|
||||
<p class="category-header__count text-muted text-sm">
|
||||
{article_count_label}
|
||||
{total_pages > 1 && ` — ${ui.pageOf(page, total_pages)}`}
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<!-- Articles grid -->
|
||||
<div class="category-grid" aria-label={`${display_name} articles`}>
|
||||
{paginated.items.map(article => (
|
||||
<ArticleCard article={article} size="md" show_excerpt={true} locale={config.locale} />
|
||||
))}
|
||||
</div>
|
||||
|
||||
{paginated.items.length === 0 && (
|
||||
<p class="empty-state">{ui.no_articles_category}</p>
|
||||
{!is_institutional && (
|
||||
<header class="category-header">
|
||||
<h1 class="category-header__title">{display_name}</h1>
|
||||
{category.description && (
|
||||
<p class="category-header__desc">{category.description}</p>
|
||||
)}
|
||||
<p class="category-header__count text-muted text-sm">
|
||||
{article_count_label}
|
||||
{total_pages > 1 && ` — ${ui.pageOf(page, total_pages)}`}
|
||||
</p>
|
||||
</header>
|
||||
)}
|
||||
|
||||
{is_institutional && (
|
||||
<header class="cat-hub-meta">
|
||||
<p class="cat-hub-meta__count text-muted text-sm">
|
||||
{article_count_label}
|
||||
{total_pages > 1 && ` — ${ui.pageOf(page, total_pages)}`}
|
||||
</p>
|
||||
</header>
|
||||
)}
|
||||
|
||||
{is_institutional ? (
|
||||
<div
|
||||
class:list={['cat-hub-content', trending.length === 0 && 'cat-hub-content--full']}
|
||||
>
|
||||
<main class="cat-hub-main">
|
||||
{lead && (
|
||||
<div class="cat-hub-lead">
|
||||
<ArticleCard article={lead} size="lg" show_excerpt={true} locale={config.locale} />
|
||||
</div>
|
||||
)}
|
||||
{grid_items.length > 0 && (
|
||||
<div class="cat-hub-grid" aria-label={`${display_name} articles`}>
|
||||
{grid_items.map(article => (
|
||||
<ArticleCard article={article} size="md" show_excerpt={true} locale={config.locale} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{paginated.items.length === 0 && (
|
||||
<p class="empty-state">{ui.no_articles_category}</p>
|
||||
)}
|
||||
</main>
|
||||
|
||||
{trending.length > 0 && (
|
||||
<aside class="cat-hub-sidebar" aria-label={ui.news_most_read}>
|
||||
<div class="cat-hub-sidebar__header">
|
||||
<h2 class="cat-hub-sidebar__title">{ui.news_most_read}</h2>
|
||||
</div>
|
||||
<ol class="cat-hub-sidebar__list">
|
||||
{trending.map((article, i) => (
|
||||
<li class="cat-hub-sidebar__item">
|
||||
<span class="cat-hub-sidebar__rank">{String(i + 1).padStart(2, '0')}</span>
|
||||
<div class="cat-hub-sidebar__body">
|
||||
<a href={`/category/${article.category.slug}`} class="cat-hub-sidebar__cat">
|
||||
{article.category.name}
|
||||
</a>
|
||||
<h3 class="cat-hub-sidebar__headline">
|
||||
<a href={`/article/${article.slug}`}>{truncate(article.title, 80)}</a>
|
||||
</h3>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</aside>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<div class="category-grid" aria-label={`${display_name} articles`}>
|
||||
{paginated.items.map(article => (
|
||||
<ArticleCard article={article} size="md" show_excerpt={true} locale={config.locale} />
|
||||
))}
|
||||
</div>
|
||||
|
||||
{paginated.items.length === 0 && (
|
||||
<p class="empty-state">{ui.no_articles_category}</p>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
<!-- Pagination -->
|
||||
{total_pages > 1 && (
|
||||
<nav class="pagination" aria-label="Pagination">
|
||||
<nav class:list={['pagination', is_institutional && 'pagination--hub']} aria-label="Pagination">
|
||||
{has_prev && (
|
||||
<a
|
||||
href={`/category/${slug}?page=${page - 1}`}
|
||||
class="pagination__item"
|
||||
aria-label={ui.prev_page}
|
||||
>←</a>
|
||||
>←</a>
|
||||
)}
|
||||
|
||||
{Array.from({ length: Math.min(total_pages, 7) }, (_, i) => {
|
||||
@@ -162,7 +247,7 @@ const breadcrumb_schema = {
|
||||
return (
|
||||
<a
|
||||
href={`/category/${slug}?page=${p}`}
|
||||
class="pagination__item"
|
||||
class:list={['pagination__item', p === page && 'pagination__item--current']}
|
||||
aria-current={p === page ? 'page' : undefined}
|
||||
>
|
||||
{p}
|
||||
@@ -175,7 +260,7 @@ const breadcrumb_schema = {
|
||||
href={`/category/${slug}?page=${page + 1}`}
|
||||
class="pagination__item"
|
||||
aria-label={ui.next_page}
|
||||
>→</a>
|
||||
>→</a>
|
||||
)}
|
||||
</nav>
|
||||
)}
|
||||
@@ -266,4 +351,240 @@ const breadcrumb_schema = {
|
||||
color: var(--color-primary);
|
||||
border-bottom-color: var(--color-primary);
|
||||
}
|
||||
|
||||
/* Institutional hub chrome — aligned with /noticias (EHF-style news sections) */
|
||||
.cat-hub-masthead {
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
var(--color-primary-dark, #0f2640) 0%,
|
||||
var(--color-primary) 48%,
|
||||
color-mix(in srgb, var(--color-secondary) 85%, #000) 100%
|
||||
);
|
||||
color: #fff;
|
||||
padding: var(--space-8) 0 var(--space-10);
|
||||
border-bottom: 4px solid color-mix(in srgb, var(--color-secondary) 70%, #fff);
|
||||
}
|
||||
|
||||
.cat-hub-masthead__eyebrow {
|
||||
font-family: var(--font-heading, inherit);
|
||||
font-size: var(--text-xs);
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.14em;
|
||||
opacity: 0.85;
|
||||
margin: 0 0 var(--space-2);
|
||||
}
|
||||
|
||||
.cat-hub-masthead__title {
|
||||
font-family: var(--font-heading, inherit);
|
||||
font-size: clamp(2rem, 5.5vw, 3.25rem);
|
||||
font-weight: 900;
|
||||
line-height: 1.05;
|
||||
letter-spacing: -0.03em;
|
||||
margin: 0;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.cat-hub-masthead__sub {
|
||||
font-size: var(--text-lg);
|
||||
line-height: 1.45;
|
||||
color: rgba(255, 255, 255, 0.88);
|
||||
margin: var(--space-4) 0 0;
|
||||
max-width: 42rem;
|
||||
}
|
||||
|
||||
.cat-hub-meta {
|
||||
padding: var(--space-4) 0 var(--space-2);
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
margin-bottom: var(--space-4);
|
||||
}
|
||||
|
||||
.cat-hub-meta__count {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.cat-hub-content {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: var(--space-8);
|
||||
margin-bottom: var(--space-8);
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
.cat-hub-content:not(.cat-hub-content--full) {
|
||||
grid-template-columns: 1fr 300px;
|
||||
gap: var(--space-10);
|
||||
}
|
||||
}
|
||||
|
||||
.cat-hub-main {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.cat-hub-lead {
|
||||
margin-bottom: var(--space-6);
|
||||
padding-bottom: var(--space-6);
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
.cat-hub-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
|
||||
gap: var(--space-5);
|
||||
}
|
||||
|
||||
@media (min-width: 640px) and (max-width: 1023px) {
|
||||
.cat-hub-grid {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
.cat-hub-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
.cat-hub-sidebar {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
.cat-hub-sidebar {
|
||||
position: sticky;
|
||||
top: var(--space-6);
|
||||
align-self: start;
|
||||
}
|
||||
}
|
||||
|
||||
.cat-hub-sidebar__header {
|
||||
padding-bottom: var(--space-3);
|
||||
border-bottom: 3px solid var(--color-primary);
|
||||
margin-bottom: var(--space-4);
|
||||
}
|
||||
|
||||
.cat-hub-sidebar__title {
|
||||
font-family: var(--font-heading, inherit);
|
||||
font-size: var(--text-base);
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
color: var(--color-primary);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.cat-hub-sidebar__list {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.cat-hub-sidebar__item {
|
||||
display: flex;
|
||||
gap: var(--space-3);
|
||||
padding: var(--space-3) 0;
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.cat-hub-sidebar__item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.cat-hub-sidebar__rank {
|
||||
flex-shrink: 0;
|
||||
font-family: var(--font-heading, inherit);
|
||||
font-size: 1.5rem;
|
||||
font-weight: 800;
|
||||
line-height: 1;
|
||||
color: var(--color-primary);
|
||||
opacity: 0.25;
|
||||
min-width: 2ch;
|
||||
}
|
||||
|
||||
.cat-hub-sidebar__body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.cat-hub-sidebar__cat {
|
||||
font-family: var(--font-heading, inherit);
|
||||
font-size: 0.6rem;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
text-decoration: none;
|
||||
color: var(--color-secondary);
|
||||
}
|
||||
|
||||
.cat-hub-sidebar__cat:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.cat-hub-sidebar__headline {
|
||||
font-family: var(--font-heading, inherit);
|
||||
font-size: var(--text-sm);
|
||||
font-weight: 700;
|
||||
line-height: 1.3;
|
||||
letter-spacing: -0.01em;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.cat-hub-sidebar__headline a {
|
||||
color: var(--color-text);
|
||||
text-decoration: none;
|
||||
transition: color 0.15s ease;
|
||||
}
|
||||
|
||||
.cat-hub-sidebar__headline a:hover {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.pagination--hub {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
padding: var(--space-8) 0 var(--space-10);
|
||||
border-top: 1px solid var(--color-border);
|
||||
margin-top: var(--space-4);
|
||||
}
|
||||
|
||||
.pagination--hub .pagination__item {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 40px;
|
||||
height: 40px;
|
||||
padding: 0 var(--space-2);
|
||||
border-radius: 6px;
|
||||
font-size: var(--text-sm);
|
||||
font-weight: 600;
|
||||
text-decoration: none;
|
||||
color: var(--color-text-muted);
|
||||
background: var(--color-bg-secondary);
|
||||
border: 1px solid var(--color-border);
|
||||
transition:
|
||||
background 0.15s ease,
|
||||
color 0.15s ease,
|
||||
border-color 0.15s ease;
|
||||
}
|
||||
|
||||
.pagination--hub .pagination__item:hover {
|
||||
color: var(--color-primary);
|
||||
border-color: var(--color-secondary);
|
||||
background: var(--color-bg);
|
||||
}
|
||||
|
||||
.pagination--hub .pagination__item--current,
|
||||
.pagination--hub .pagination__item[aria-current='page'] {
|
||||
color: #fff;
|
||||
background: var(--color-primary);
|
||||
border-color: var(--color-primary);
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user