From 919153aaf7528edfdfcd0173b3d2faaa346944ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Alves?= Date: Thu, 18 Jun 2026 10:09:35 +0000 Subject: [PATCH 1/2] fix(frontend): force pt-PT locale and handball-only for andebol.net (BIT-25555) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause: DOMAINS_CONFIG_PATH was missing from the frontend env so getDomainConfig('andebol.net') fell through to the English fallback. Fixes applied: - deploy/systemd/frontend.env.example: add DOMAINS_CONFIG_PATH and BRIDGE_INTERNAL_URL so Astro SSR resolves domain JSON on the CT - bridge/src/lib/request-host.ts: drop X-Site-Host; resolve site domain from the HTTP Host header which nginx already preserves ($host) - frontend/src/lib/bridge.ts: multi-domain SWR cache keys; nginx-routed bridge calls via public hostname with BRIDGE_INTERNAL_URL loopback override for CT environments where public DNS does not resolve locally - config/writers/f0251a61: restrict Nelson Alves topics to Andebol only (remove Futebol / Desportos — BIT-22288 intent) - frontend: overhauled article page (hero image, masthead, sidebar, share bar), rich related-articles grid, improved LatestGrid institutional theme, FpaAgendaSection rewrite, ui-i18n PT strings completed --- bridge/src/lib/request-host.ts | 6 +- .../f0251a61-38e1-4a9b-8cd1-38d96a320cab.json | 4 +- deploy/systemd/frontend.env.example | 9 +- .../components/article/ArticleHeader.astro | 93 ++- .../components/article/ArticleShareBar.astro | 143 +++++ .../components/article/ArticleSidebar.astro | 288 +++++++++ .../components/article/RelatedArticles.astro | 198 +++++- frontend/src/components/home/LatestGrid.astro | 66 +- frontend/src/lib/bridge.test.ts | 42 ++ frontend/src/lib/bridge.ts | 112 +++- frontend/src/lib/ui-i18n.ts | 32 + frontend/src/pages/article/[slug].astro | 345 +++++++++-- frontend/src/styles/global.css | 103 +++- .../institutional/FpaAgendaSection.astro | 572 ++++++++++++++---- .../src/backfill-featured-smart.ts | 378 ++++++++++++ 15 files changed, 2136 insertions(+), 255 deletions(-) create mode 100644 frontend/src/components/article/ArticleShareBar.astro create mode 100644 frontend/src/components/article/ArticleSidebar.astro create mode 100644 frontend/src/lib/bridge.test.ts create mode 100644 writer-pipeline/src/backfill-featured-smart.ts diff --git a/bridge/src/lib/request-host.ts b/bridge/src/lib/request-host.ts index eee3d76..b92d735 100644 --- a/bridge/src/lib/request-host.ts +++ b/bridge/src/lib/request-host.ts @@ -2,13 +2,9 @@ import type { FastifyRequest } from 'fastify'; /** * Public site hostname for domain config + cache keys. - * SSR calls the bridge on loopback; the browser Host is forwarded via X-Site-Host. + * Resolved from the HTTP Host header (nginx preserves $host on /api/ proxy). */ export function resolve_site_host(req: FastifyRequest): string { - const raw = req.headers['x-site-host']; - if (typeof raw === 'string' && raw.trim()) { - return raw.split(':')[0].toLowerCase(); - } const hostname = req.hostname ?? 'localhost'; return hostname.replace(/:\d+$/, '').toLowerCase(); } diff --git a/config/writers/f0251a61-38e1-4a9b-8cd1-38d96a320cab.json b/config/writers/f0251a61-38e1-4a9b-8cd1-38d96a320cab.json index 08cdca2..1016cd6 100644 --- a/config/writers/f0251a61-38e1-4a9b-8cd1-38d96a320cab.json +++ b/config/writers/f0251a61-38e1-4a9b-8cd1-38d96a320cab.json @@ -4,9 +4,7 @@ "role": "AI News Writer", "domain": "andebol.net", "topics": [ - "Andebol", - "Futebol", - "Desportos" + "Andebol" ], "sources": [ { diff --git a/deploy/systemd/frontend.env.example b/deploy/systemd/frontend.env.example index b2e1dc7..d51989e 100644 --- a/deploy/systemd/frontend.env.example +++ b/deploy/systemd/frontend.env.example @@ -5,8 +5,15 @@ HOST=0.0.0.0 PORT=4321 -# Bridge API base URL (internal, from Astro server-side) +# Bridge API base URL — used by Astro SSR when BRIDGE_INTERNAL_URL is not set. BRIDGE_API_URL=http://127.0.0.1:3200 +# Domain JSON directory (SSR must resolve andebol.net vs newsproject — BIT-25555) +DOMAINS_CONFIG_PATH=/opt/news-platform/config/domains + +# Direct loopback override for bridge calls. Set this when the CT cannot resolve the +# public hostname (e.g. andebol.net) back to itself via DNS. Overrides nginx-routed calls. +BRIDGE_INTERNAL_URL=http://127.0.0.1:3200 + # Site domain (used for canonical URLs, sitemaps, etc.) SITE_URL=https://newsproject.bitreport.pt diff --git a/frontend/src/components/article/ArticleHeader.astro b/frontend/src/components/article/ArticleHeader.astro index 033f1a8..18304d6 100644 --- a/frontend/src/components/article/ArticleHeader.astro +++ b/frontend/src/components/article/ArticleHeader.astro @@ -8,36 +8,49 @@ interface Props { locale: string; /** When false, parent layout already renders a localized breadcrumb (e.g. institutional theme). */ showBreadcrumb?: boolean; + /** meta-only: skip title/excerpt (rendered in masthead/hero); full: default article header */ + variant?: 'full' | 'meta-only'; + /** Light text for hero overlay */ + theme?: 'default' | 'dark'; } -const { article, locale, showBreadcrumb = true } = Astro.props; + +const { + article, + locale, + showBreadcrumb = true, + variant = 'full', + theme = 'default', +} = Astro.props; const ui = getUiStrings(locale); +const is_meta_only = variant === 'meta-only'; +const is_dark = theme === 'dark'; --- -
- {showBreadcrumb && ( - +
+ {showBreadcrumb && !is_meta_only && ( + )} - -
- {article.category.name} - {article.tags.slice(0, 3).map(tag => ( - {tag.name} - ))} -
+ {!is_meta_only && ( + <> +
+ {article.category.name} + {article.tags.slice(0, 3).map(tag => ( + {tag.name} + ))} +
- -

{article.title}

+

{article.title}

- -

{article.excerpt}

+ {article.excerpt &&

{article.excerpt}

} + + )} -
{article.author.avatar ? ( @@ -89,6 +102,24 @@ const ui = getUiStrings(locale); margin-bottom: var(--space-6); } + .article-header--meta { + padding-bottom: 0; + border-bottom: none; + margin-bottom: 0; + gap: var(--space-3); + } + + .article-header--dark .article-header__author-name, + .article-header--dark .article-header__date, + .article-header--dark .article-header__reading { + color: rgba(255, 255, 255, 0.85); + } + + .article-header--dark .article-header__avatar--placeholder { + background: rgba(255, 255, 255, 0.2); + border: 2px solid rgba(255, 255, 255, 0.4); + } + .article-header__cats { display: flex; gap: var(--space-2); @@ -167,5 +198,23 @@ const ui = getUiStrings(locale); font-size: var(--text-sm); color: var(--color-text-muted); white-space: nowrap; + padding: 0.35em 0.75em; + background: var(--color-bg-secondary); + border-radius: 999px; + font-weight: 600; + } + + .article-header--dark .article-header__reading { + background: rgba(255, 255, 255, 0.12); + } + + .article-header--meta .article-header__reading { + background: transparent; + padding: 0; + } + + .article-header--dark.article-header--meta .article-header__reading { + background: rgba(255, 255, 255, 0.1); + padding: 0.35em 0.75em; } diff --git a/frontend/src/components/article/ArticleShareBar.astro b/frontend/src/components/article/ArticleShareBar.astro new file mode 100644 index 0000000..a3fcdbf --- /dev/null +++ b/frontend/src/components/article/ArticleShareBar.astro @@ -0,0 +1,143 @@ +--- +import { getUiStrings } from '../../lib/ui-i18n.js'; + +interface Props { + url: string; + title: string; + locale: string; +} + +const { url, title, locale } = Astro.props; +const ui = getUiStrings(locale); +const encoded_url = encodeURIComponent(url); +const encoded_title = encodeURIComponent(title); +--- +
+ {ui.share_heading} +
+ + + + {ui.share_twitter} + + + + {ui.share_facebook} + + + + {ui.share_whatsapp} + +
+
+ + + + diff --git a/frontend/src/components/article/ArticleSidebar.astro b/frontend/src/components/article/ArticleSidebar.astro new file mode 100644 index 0000000..86f1f71 --- /dev/null +++ b/frontend/src/components/article/ArticleSidebar.astro @@ -0,0 +1,288 @@ +--- +import type { Article, ArticleListItem, CategoryConfig } from '../../types/index.js'; +import { truncate } from '../../lib/format.js'; +import { getUiStrings } from '../../lib/ui-i18n.js'; + +interface Props { + article: Article; + trending: ArticleListItem[]; + categories: CategoryConfig[]; + locale: string; + ads_enabled?: boolean; +} + +const { article, trending, categories, locale, ads_enabled = false } = Astro.props; +const ui = getUiStrings(locale); +const filtered_trending = trending.filter(t => t.slug !== article.slug).slice(0, 5); +--- + + + diff --git a/frontend/src/components/article/RelatedArticles.astro b/frontend/src/components/article/RelatedArticles.astro index faeb383..5ac6b3c 100644 --- a/frontend/src/components/article/RelatedArticles.astro +++ b/frontend/src/components/article/RelatedArticles.astro @@ -1,6 +1,7 @@ --- import type { ArticleListItem } from '../../types/index.js'; import { getThemeComponents } from '../../lib/theme.js'; +import { relativeTime, truncate } from '../../lib/format.js'; import { getUiStrings } from '../../lib/ui-i18n.js'; interface Props { @@ -14,8 +15,51 @@ const ui = getUiStrings(locale); --- {articles.length > 0 && (