From f3e56f4b1471caeac2d1672f4285c66b1bbebb4d Mon Sep 17 00:00:00 2001 From: Artur Moreira Date: Mon, 30 Mar 2026 02:07:16 +0000 Subject: [PATCH] feat(andebol): redesign /noticias as magazine-style layout (BIT-623) Replace uniform 3-column grid with rich newspaper-inspired layout: - Secondary featured row (top stories cards) below hero - Lead article displayed as large card for visual hierarchy - Two-column main+sidebar layout on desktop - "Most Read" trending sidebar with numbered article list - Mixed card sizes (lg lead + md grid) instead of monotonous grid - New i18n string: news_most_read (pt-PT + en) Co-Authored-By: Paperclip --- frontend/src/lib/ui-i18n.ts | 4 + frontend/src/pages/noticias.astro | 462 +++++++++++++++++++++++++++--- 2 files changed, 431 insertions(+), 35 deletions(-) diff --git a/frontend/src/lib/ui-i18n.ts b/frontend/src/lib/ui-i18n.ts index c02e259..8cbc793 100644 --- a/frontend/src/lib/ui-i18n.ts +++ b/frontend/src/lib/ui-i18n.ts @@ -59,6 +59,8 @@ export type UiStrings = { news_all_filter: string; /** News archive page meta description */ news_archive_desc: string; + /** Sidebar label for trending / most-read articles */ + news_most_read: string; }; const en: UiStrings = { @@ -113,6 +115,7 @@ const en: UiStrings = { news_archive_title: 'News', news_all_filter: 'All', news_archive_desc: 'Latest news and stories across all sections.', + news_most_read: 'Most Read', }; const pt: UiStrings = { @@ -167,6 +170,7 @@ const pt: UiStrings = { news_archive_title: 'Notícias', news_all_filter: 'Todas', news_archive_desc: 'Últimas notícias e histórias de todas as secções.', + news_most_read: 'Mais Lidas', }; export function getUiStrings(locale: string): UiStrings { diff --git a/frontend/src/pages/noticias.astro b/frontend/src/pages/noticias.astro index b2d7801..db11eb4 100644 --- a/frontend/src/pages/noticias.astro +++ b/frontend/src/pages/noticias.astro @@ -27,18 +27,25 @@ try { bridge = new MockBridgeClient(); } -/* Hero: show on first page without category filter */ -let hero: Awaited>['hero'][number] | null = null; +/* ── Hero + secondary featured (page 1, no category filter) ── */ +type HeroArticle = Awaited>['hero'][number]; +let hero: HeroArticle | null = null; +let secondary_featured: HeroArticle[] = []; if (page === 1 && !active_cat) { try { const homepage = await bridge.getHomepage(); hero = homepage.hero[0] ?? null; - } catch { - /* fall through */ - } + secondary_featured = homepage.hero.slice(1, 4); + } catch { /* fall through */ } } -/* Paginated article list */ +/* ── Trending sidebar ── */ +let trending: Awaited> = []; +try { + trending = await bridge.getTrending(6); +} catch { /* fall through */ } + +/* ── Paginated article list ── */ let paginated: Awaited>; try { paginated = await bridge.getArticles({ @@ -50,23 +57,29 @@ try { paginated = { items: [], total: 0, page: 1, per_page, total_pages: 0 }; } -/* Deduplicate hero from grid */ -const grid_items = hero - ? paginated.items.filter(a => a.slug !== hero!.slug) - : paginated.items; +/* ── Deduplicate hero + secondary from grid ── */ +const shown_slugs = new Set(); +if (hero) shown_slugs.add(hero.slug); +secondary_featured.forEach(a => shown_slugs.add(a.slug)); + +const deduped = paginated.items.filter(a => !shown_slugs.has(a.slug)); + +/* Split: lead article (large) + remaining grid */ +const lead = deduped[0] ?? null; +const grid_items = lead ? deduped.slice(1) : []; const total_pages = paginated.total_pages; const has_prev = page > 1; const has_next = page < total_pages; const categories = config.categories; -/* Canonical URL */ +/* ── Canonical URL ── */ const qs_parts: string[] = []; if (active_cat) qs_parts.push(`cat=${active_cat}`); if (page > 1) qs_parts.push(`page=${page}`); const canonical = `${Astro.url.origin}/noticias${qs_parts.length ? '?' + qs_parts.join('&') : ''}`; -/* Active category label for meta */ +/* ── Active category label for meta ── */ const active_cat_label = active_cat ? categories.find(c => c.slug === active_cat)?.label ?? active_cat : ''; @@ -74,7 +87,7 @@ const page_title = active_cat_label ? `${active_cat_label} — ${ui.news_archive_title} — ${config.site_name}` : `${ui.news_archive_title} — ${config.site_name}`; -/* Pagination link builder */ +/* ── Pagination link builder ── */ function paginationHref(p: number): string { const parts: string[] = []; if (active_cat) parts.push(`cat=${active_cat}`); @@ -98,7 +111,9 @@ const breadcrumb_schema = { canonical={canonical} schema={breadcrumb_schema} > - {/* ── Hero banner (page 1, no filter) ── */} + {/* ══════════════════════════════════════════════════════════ + HERO BANNER (page 1, no filter) + ══════════════════════════════════════════════════════════ */} {hero && (
+
+ )} +
- {/* ── Page heading (shown when no hero, or when filtering) ── */} + {/* ── Page heading (when no hero — page 2+, or category filter) ── */} {!hero && (

{active_cat_label || ui.news_archive_title}

@@ -155,7 +210,9 @@ const breadcrumb_schema = {
)} - {/* ── Category filter tabs ── */} + {/* ══════════════════════════════════════════════════════════ + CATEGORY FILTER TABS + ══════════════════════════════════════════════════════════ */} - {/* ── Article grid ── */} -
- {grid_items.map(article => ( - - ))} + {/* ══════════════════════════════════════════════════════════ + MAIN + SIDEBAR LAYOUT + ══════════════════════════════════════════════════════════ */} + - {grid_items.length === 0 && ( -

{ui.no_articles_category}

- )} - - {/* ── Pagination ── */} + {/* ══════════════════════════════════════════════════════════ + PAGINATION + ══════════════════════════════════════════════════════════ */} {total_pages > 1 && (