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 <[email protected]>
This commit is contained in:
1 parent
7869b25b2a
commit
f3e56f4b14
2 files changed
+431
-35
No files matched your search
@@ -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 {
|
||||
|
||||
@@ -27,18 +27,25 @@ try {
|
||||
bridge = new MockBridgeClient();
|
||||
}
|
||||
|
||||
/* Hero: show on first page without category filter */
|
||||
let hero: Awaited<ReturnType<BridgeClient['getHomepage']>>['hero'][number] | null = null;
|
||||
/* ── Hero + secondary featured (page 1, no category filter) ── */
|
||||
type HeroArticle = Awaited<ReturnType<BridgeClient['getHomepage']>>['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<ReturnType<BridgeClient['getTrending']>> = [];
|
||||
try {
|
||||
trending = await bridge.getTrending(6);
|
||||
} catch { /* fall through */ }
|
||||
|
||||
/* ── Paginated article list ── */
|
||||
let paginated: Awaited<ReturnType<BridgeClient['getArticles']>>;
|
||||
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<string>();
|
||||
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 && (
|
||||
<section class="na-hero" aria-label={ui.featured}>
|
||||
<a href={`/article/${hero.slug}`} class="na-hero__media" aria-hidden="true" tabindex="-1">
|
||||
@@ -141,8 +156,48 @@ const breadcrumb_schema = {
|
||||
</section>
|
||||
)}
|
||||
|
||||
{/* ══════════════════════════════════════════════════════════
|
||||
SECONDARY FEATURED ROW (page 1, below hero)
|
||||
══════════════════════════════════════════════════════════ */}
|
||||
{secondary_featured.length > 0 && (
|
||||
<section class="na-top-stories" aria-label={ui.featured}>
|
||||
<div class="container">
|
||||
<div class="na-top-stories__grid">
|
||||
{secondary_featured.map(article => (
|
||||
<article class="na-top-stories__card">
|
||||
<a href={`/article/${article.slug}`} class="na-top-stories__thumb" tabindex="-1" aria-hidden="true">
|
||||
{article.featured_image ? (
|
||||
<img
|
||||
src={article.featured_image}
|
||||
alt={article.featured_image_alt}
|
||||
class="na-top-stories__img"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
width="400"
|
||||
height="225"
|
||||
/>
|
||||
) : (
|
||||
<div class="na-top-stories__img na-top-stories__img--empty" aria-hidden="true" />
|
||||
)}
|
||||
</a>
|
||||
<div class="na-top-stories__body">
|
||||
<a href={`/category/${article.category.slug}`} class="na-top-stories__cat">{article.category.name}</a>
|
||||
<h2 class="na-top-stories__headline">
|
||||
<a href={`/article/${article.slug}`}>{article.title}</a>
|
||||
</h2>
|
||||
<time class="na-top-stories__date" datetime={article.published_at}>
|
||||
{relativeTime(article.published_at, config.locale)}
|
||||
</time>
|
||||
</div>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
|
||||
<div class="container">
|
||||
{/* ── Page heading (shown when no hero, or when filtering) ── */}
|
||||
{/* ── Page heading (when no hero — page 2+, or category filter) ── */}
|
||||
{!hero && (
|
||||
<header class="na-header">
|
||||
<h1 class="na-header__title">{active_cat_label || ui.news_archive_title}</h1>
|
||||
@@ -155,7 +210,9 @@ const breadcrumb_schema = {
|
||||
</header>
|
||||
)}
|
||||
|
||||
{/* ── Category filter tabs ── */}
|
||||
{/* ══════════════════════════════════════════════════════════
|
||||
CATEGORY FILTER TABS
|
||||
══════════════════════════════════════════════════════════ */}
|
||||
<nav class="na-tabs" aria-label={ui.sections_categories}>
|
||||
<div class="na-tabs__scroll">
|
||||
<a
|
||||
@@ -177,18 +234,60 @@ const breadcrumb_schema = {
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
{/* ── Article grid ── */}
|
||||
<div class="na-grid" aria-label={`${ui.news_archive_title} articles`}>
|
||||
{grid_items.map(article => (
|
||||
<ArticleCard article={article} size="md" show_excerpt={true} locale={config.locale} />
|
||||
))}
|
||||
{/* ══════════════════════════════════════════════════════════
|
||||
MAIN + SIDEBAR LAYOUT
|
||||
══════════════════════════════════════════════════════════ */}
|
||||
<div class="na-content">
|
||||
<main class="na-main">
|
||||
{/* ── Lead article (large card) ── */}
|
||||
{lead && (
|
||||
<div class="na-lead">
|
||||
<ArticleCard article={lead} size="lg" show_excerpt={true} locale={config.locale} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ── Article grid ── */}
|
||||
{grid_items.length > 0 && (
|
||||
<div class="na-grid" aria-label={`${ui.news_archive_title} articles`}>
|
||||
{grid_items.map(article => (
|
||||
<ArticleCard article={article} size="md" show_excerpt={true} locale={config.locale} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{deduped.length === 0 && (
|
||||
<p class="na-empty">{ui.no_articles_category}</p>
|
||||
)}
|
||||
</main>
|
||||
|
||||
{/* ══════════════════════════════════════════════════════════
|
||||
TRENDING SIDEBAR
|
||||
══════════════════════════════════════════════════════════ */}
|
||||
{trending.length > 0 && (
|
||||
<aside class="na-sidebar" aria-label={ui.news_most_read}>
|
||||
<div class="na-sidebar__header">
|
||||
<h2 class="na-sidebar__title">{ui.news_most_read}</h2>
|
||||
</div>
|
||||
<ol class="na-sidebar__list">
|
||||
{trending.map((article, i) => (
|
||||
<li class="na-sidebar__item">
|
||||
<span class="na-sidebar__rank">{String(i + 1).padStart(2, '0')}</span>
|
||||
<div class="na-sidebar__body">
|
||||
<a href={`/category/${article.category.slug}`} class="na-sidebar__cat">{article.category.name}</a>
|
||||
<h3 class="na-sidebar__headline">
|
||||
<a href={`/article/${article.slug}`}>{truncate(article.title, 80)}</a>
|
||||
</h3>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</aside>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{grid_items.length === 0 && (
|
||||
<p class="na-empty">{ui.no_articles_category}</p>
|
||||
)}
|
||||
|
||||
{/* ── Pagination ── */}
|
||||
{/* ══════════════════════════════════════════════════════════
|
||||
PAGINATION
|
||||
══════════════════════════════════════════════════════════ */}
|
||||
{total_pages > 1 && (
|
||||
<nav class="pagination" aria-label="Pagination">
|
||||
{has_prev && (
|
||||
@@ -204,7 +303,7 @@ const breadcrumb_schema = {
|
||||
return (
|
||||
<a
|
||||
href={paginationHref(p)}
|
||||
class="pagination__item"
|
||||
class:list={['pagination__item', p === page && 'pagination__item--current']}
|
||||
aria-current={p === page ? 'page' : undefined}
|
||||
>
|
||||
{p}
|
||||
@@ -225,7 +324,9 @@ const breadcrumb_schema = {
|
||||
</Base>
|
||||
|
||||
<style>
|
||||
/* ── Hero banner ── */
|
||||
/* ═══════════════════════════════════════════════════════════
|
||||
HERO BANNER
|
||||
═══════════════════════════════════════════════════════════ */
|
||||
.na-hero {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
@@ -334,9 +435,118 @@ const breadcrumb_schema = {
|
||||
margin-top: var(--space-3);
|
||||
}
|
||||
|
||||
/* ── Page header (no hero) ── */
|
||||
/* ═══════════════════════════════════════════════════════════
|
||||
SECONDARY FEATURED ROW (top stories below hero)
|
||||
═══════════════════════════════════════════════════════════ */
|
||||
.na-top-stories {
|
||||
background: var(--color-bg-secondary);
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
padding: var(--space-6) 0;
|
||||
}
|
||||
|
||||
.na-top-stories__grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: var(--space-5);
|
||||
}
|
||||
|
||||
@media (min-width: 640px) {
|
||||
.na-top-stories__grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 900px) {
|
||||
.na-top-stories__grid {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
.na-top-stories__card {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: start;
|
||||
gap: var(--space-4);
|
||||
padding: var(--space-4);
|
||||
background: var(--color-bg-card, var(--color-bg));
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--inst-radius-lg, 8px);
|
||||
transition: box-shadow 0.15s ease, border-color 0.15s ease;
|
||||
}
|
||||
|
||||
.na-top-stories__card:hover {
|
||||
border-color: var(--color-secondary);
|
||||
box-shadow: 0 4px 16px rgba(26, 58, 92, 0.08);
|
||||
}
|
||||
|
||||
.na-top-stories__thumb {
|
||||
display: block;
|
||||
flex-shrink: 0;
|
||||
width: 120px;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.na-top-stories__img {
|
||||
width: 120px;
|
||||
height: 80px;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.na-top-stories__img--empty {
|
||||
background: var(--color-accent);
|
||||
}
|
||||
|
||||
.na-top-stories__body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.na-top-stories__cat {
|
||||
align-self: flex-start;
|
||||
font-size: 0.65rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
text-decoration: none;
|
||||
color: var(--color-secondary);
|
||||
}
|
||||
|
||||
.na-top-stories__cat:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.na-top-stories__headline {
|
||||
font-family: var(--font-heading, inherit);
|
||||
font-size: var(--text-sm);
|
||||
font-weight: 600;
|
||||
line-height: 1.35;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.na-top-stories__headline a {
|
||||
color: var(--color-text);
|
||||
text-decoration: none;
|
||||
transition: color 0.15s ease;
|
||||
}
|
||||
|
||||
.na-top-stories__headline a:hover {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.na-top-stories__date {
|
||||
font-size: var(--text-xs);
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
/* ═══════════════════════════════════════════════════════════
|
||||
PAGE HEADER (no hero — page 2+ or category filter)
|
||||
═══════════════════════════════════════════════════════════ */
|
||||
.na-header {
|
||||
padding: var(--space-6) 0 var(--space-4);
|
||||
padding: var(--space-8) 0 var(--space-4);
|
||||
border-bottom: 3px solid var(--color-primary);
|
||||
margin-bottom: var(--space-2);
|
||||
}
|
||||
@@ -352,7 +562,9 @@ const breadcrumb_schema = {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* ── Category tabs ── */
|
||||
/* ═══════════════════════════════════════════════════════════
|
||||
CATEGORY TABS
|
||||
═══════════════════════════════════════════════════════════ */
|
||||
.na-tabs {
|
||||
padding: var(--space-5) 0 var(--space-6);
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
@@ -409,24 +621,204 @@ const breadcrumb_schema = {
|
||||
border-color: var(--color-primary);
|
||||
}
|
||||
|
||||
/* ── Article grid ── */
|
||||
.na-grid {
|
||||
/* ═══════════════════════════════════════════════════════════
|
||||
MAIN + SIDEBAR LAYOUT
|
||||
═══════════════════════════════════════════════════════════ */
|
||||
.na-content {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
||||
gap: var(--space-5);
|
||||
grid-template-columns: 1fr;
|
||||
gap: var(--space-8);
|
||||
margin-bottom: var(--space-8);
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
.na-content {
|
||||
grid-template-columns: 1fr 300px;
|
||||
gap: var(--space-10);
|
||||
}
|
||||
}
|
||||
|
||||
/* ── Main column ── */
|
||||
.na-main {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.na-lead {
|
||||
margin-bottom: var(--space-6);
|
||||
padding-bottom: var(--space-6);
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
.na-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
|
||||
gap: var(--space-5);
|
||||
}
|
||||
|
||||
@media (min-width: 640px) and (max-width: 1023px) {
|
||||
.na-grid {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
.na-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
.na-empty {
|
||||
text-align: center;
|
||||
padding: var(--space-12);
|
||||
color: var(--color-text-muted);
|
||||
font-size: var(--text-lg);
|
||||
}
|
||||
|
||||
/* ═══════════════════════════════════════════════════════════
|
||||
TRENDING SIDEBAR
|
||||
═══════════════════════════════════════════════════════════ */
|
||||
.na-sidebar {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
.na-sidebar {
|
||||
position: sticky;
|
||||
top: var(--space-6);
|
||||
align-self: start;
|
||||
}
|
||||
}
|
||||
|
||||
.na-sidebar__header {
|
||||
padding-bottom: var(--space-3);
|
||||
border-bottom: 3px solid var(--color-primary);
|
||||
margin-bottom: var(--space-4);
|
||||
}
|
||||
|
||||
.na-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;
|
||||
}
|
||||
|
||||
.na-sidebar__list {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0;
|
||||
counter-reset: sidebar-rank;
|
||||
}
|
||||
|
||||
.na-sidebar__item {
|
||||
display: flex;
|
||||
gap: var(--space-3);
|
||||
padding: var(--space-3) 0;
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.na-sidebar__item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.na-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;
|
||||
}
|
||||
|
||||
.na-sidebar__body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.na-sidebar__cat {
|
||||
font-size: 0.6rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
text-decoration: none;
|
||||
color: var(--color-secondary);
|
||||
}
|
||||
|
||||
.na-sidebar__cat:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.na-sidebar__headline {
|
||||
font-family: var(--font-heading, inherit);
|
||||
font-size: var(--text-sm);
|
||||
font-weight: 600;
|
||||
line-height: 1.35;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.na-sidebar__headline a {
|
||||
color: var(--color-text);
|
||||
text-decoration: none;
|
||||
transition: color 0.15s ease;
|
||||
}
|
||||
|
||||
.na-sidebar__headline a:hover {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
/* ═══════════════════════════════════════════════════════════
|
||||
PAGINATION (enhanced)
|
||||
═══════════════════════════════════════════════════════════ */
|
||||
.pagination {
|
||||
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__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__item:hover {
|
||||
color: var(--color-primary);
|
||||
border-color: var(--color-secondary);
|
||||
background: var(--color-bg);
|
||||
}
|
||||
|
||||
.pagination__item--current,
|
||||
.pagination__item[aria-current="page"] {
|
||||
color: #fff;
|
||||
background: var(--color-primary);
|
||||
border-color: var(--color-primary);
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user