feat: build Astro 6 SSR frontend for multi-domain sports news platform #2

Merged
spark merged 2 commits from task/BIT-349-astro-frontend into main 2026-03-23 14:55:44 +00:00
33 changed files with 7728 additions and 0 deletions

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
# News Platform Frontend — Environment variables
# Copy to .env and adjust for local development
# Port (default: 4321)
PORT=4321
# Host to bind (default: 0.0.0.0 for production, localhost for dev)
HOST=localhost
+24
View File
@@ -0,0 +1,24 @@
# build output
dist/
# generated types
.astro/
# dependencies
node_modules/
# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# environment variables
.env
.env.production
# macOS-specific files
.DS_Store
# jetbrains setting folder
.idea/
+1
View File
@@ -0,0 +1 @@
22
+4
View File
@@ -0,0 +1,4 @@
{
"recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": []
}
+11
View File
@@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "./node_modules/.bin/astro dev",
"name": "Development server",
"request": "launch",
"type": "node-terminal"
}
]
}
+43
View File
@@ -0,0 +1,43 @@
# Astro Starter Kit: Minimal
```sh
npm create astro@latest -- --template minimal
```
> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!
## 🚀 Project Structure
Inside of your Astro project, you'll see the following folders and files:
```text
/
├── public/
├── src/
│ └── pages/
│ └── index.astro
└── package.json
```
Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name.
There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components.
Any static assets, like images, can be placed in the `public/` directory.
## 🧞 Commands
All commands are run from the root of the project, from a terminal:
| Command | Action |
| :------------------------ | :----------------------------------------------- |
| `npm install` | Installs dependencies |
| `npm run dev` | Starts local dev server at `localhost:4321` |
| `npm run build` | Build your production site to `./dist/` |
| `npm run preview` | Preview your build locally, before deploying |
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
| `npm run astro -- --help` | Get help using the Astro CLI |
## 👀 Want to learn more?
Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat).
+18
View File
@@ -0,0 +1,18 @@
// @ts-check
import { defineConfig } from 'astro/config';
import node from '@astrojs/node';
// https://astro.build/config
export default defineConfig({
output: 'server',
adapter: node({
mode: 'standalone',
}),
server: {
port: 4321,
host: true,
},
image: {
domains: ['*'],
},
});
+4886
View File
File diff suppressed because it is too large. Load diff
+19
View File
@@ -0,0 +1,19 @@
{
"name": "news-platform-frontend",
"type": "module",
"version": "0.1.0",
"description": "Astro SSR frontend for multi-domain sports news platform",
"engines": {
"node": ">=22.12.0"
},
"scripts": {
"dev": "astro dev",
"build": "astro build",
"preview": "astro preview",
"astro": "astro"
},
"dependencies": {
"@astrojs/node": "^10.0.3",
"astro": "^6.0.8"
}
}
+6
View File
@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 40" aria-label="Sports News">
<rect x="0" y="4" width="32" height="32" rx="5" fill="#e63946"/>
<text x="4" y="29" font-size="24" font-weight="900" font-family="Arial,sans-serif" fill="white">S</text>
<text x="42" y="29" font-size="22" font-weight="900" font-family="Arial,sans-serif" fill="#1d3557">SPORTS</text>
<text x="42" y="29" font-size="22" font-weight="900" font-family="Arial,sans-serif" fill="#e63946" x="106">N</text>
</svg>

After

Width:  |  Height:  |  Size: 501 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 655 B

+4
View File
@@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
<rect width="32" height="32" rx="6" fill="#e63946"/>
<text x="5" y="24" font-size="20" font-weight="900" font-family="Arial,sans-serif" fill="white">S</text>
</svg>

After

Width:  |  Height:  |  Size: 230 B

@@ -0,0 +1,162 @@
---
import type { Article } from '../../types/index.js';
import { formatDate, relativeTime } from '../../lib/format.js';
interface Props {
article: Article;
}
const { article } = Astro.props;
---
<header class="article-header">
<!-- Breadcrumb -->
<nav class="breadcrumb" aria-label="Breadcrumb">
<a href="/">Home</a>
<span class="breadcrumb__sep" aria-hidden="true">/</span>
<a href={`/category/${article.category.slug}`}>{article.category.name}</a>
<span class="breadcrumb__sep" aria-hidden="true">/</span>
<span aria-current="page">{article.title}</span>
</nav>
<!-- Category -->
<div class="article-header__cats">
<a href={`/category/${article.category.slug}`} class="badge">{article.category.name}</a>
{article.tags.slice(0, 3).map(tag => (
<span class="badge badge--muted">{tag.name}</span>
))}
</div>
<!-- Title -->
<h1 class="article-header__title">{article.title}</h1>
<!-- Excerpt -->
<p class="article-header__excerpt">{article.excerpt}</p>
<!-- Meta -->
<div class="article-header__meta">
<div class="article-header__author">
{article.author.avatar ? (
<img
src={article.author.avatar}
alt={article.author.name}
width="40"
height="40"
class="article-header__avatar"
loading="lazy"
/>
) : (
<div class="article-header__avatar article-header__avatar--placeholder" aria-hidden="true">
{article.author.name.charAt(0).toUpperCase()}
</div>
)}
<div>
<p class="article-header__author-name">{article.author.name}</p>
<p class="article-header__date">
<time datetime={article.published_at} title={formatDate(article.published_at)}>
{relativeTime(article.published_at)}
</time>
{article.updated_at !== article.published_at && (
<span class="article-header__updated">
· Updated <time datetime={article.updated_at}>{relativeTime(article.updated_at)}</time>
</span>
)}
</p>
</div>
</div>
<div class="article-header__reading">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
<circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/>
</svg>
{article.reading_time} min read
</div>
</div>
</header>
<style>
.article-header {
display: flex;
flex-direction: column;
gap: var(--space-4);
padding-bottom: var(--space-6);
border-bottom: 1px solid var(--color-border);
margin-bottom: var(--space-6);
}
.article-header__cats {
display: flex;
gap: var(--space-2);
flex-wrap: wrap;
}
.article-header__title {
font-size: clamp(1.75rem, 4vw, 2.75rem);
font-weight: 900;
line-height: 1.15;
color: var(--color-text);
}
.article-header__excerpt {
font-size: var(--text-lg);
color: var(--color-text-muted);
line-height: 1.6;
font-style: italic;
border-left: 3px solid var(--color-primary);
padding-left: var(--space-4);
}
.article-header__meta {
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--space-4);
flex-wrap: wrap;
}
.article-header__author {
display: flex;
align-items: center;
gap: var(--space-3);
}
.article-header__avatar {
width: 40px;
height: 40px;
border-radius: 50%;
object-fit: cover;
flex-shrink: 0;
}
.article-header__avatar--placeholder {
background: var(--color-primary);
color: #fff;
display: flex;
align-items: center;
justify-content: center;
font-weight: 700;
font-size: var(--text-sm);
}
.article-header__author-name {
font-weight: 600;
font-size: var(--text-sm);
color: var(--color-text);
}
.article-header__date {
font-size: var(--text-xs);
color: var(--color-text-muted);
}
.article-header__updated {
opacity: 0.7;
}
.article-header__reading {
display: flex;
align-items: center;
gap: var(--space-2);
font-size: var(--text-sm);
color: var(--color-text-muted);
white-space: nowrap;
}
</style>
@@ -0,0 +1,34 @@
---
import type { ArticleListItem } from '../../types/index.js';
import ArticleCard from '../shared/ArticleCard.astro';
interface Props {
articles: ArticleListItem[];
}
const { articles } = Astro.props;
---
{articles.length > 0 && (
<section class="related-section" aria-labelledby="related-title">
<h2 class="section-title" id="related-title">Related Articles</h2>
<div class="related-grid">
{articles.map(article => (
<ArticleCard article={article} size="md" show_excerpt={false} />
))}
</div>
</section>
)}
<style>
.related-section {
margin-top: var(--space-12);
padding-top: var(--space-8);
border-top: 1px solid var(--color-border);
}
.related-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
gap: var(--space-5);
margin-top: var(--space-5);
}
</style>
@@ -0,0 +1,72 @@
---
import type { ArticleListItem, CategoryConfig } from '../../types/index.js';
import ArticleCard from '../shared/ArticleCard.astro';
interface Props {
category: CategoryConfig;
articles: ArticleListItem[];
}
const { category, articles } = Astro.props;
---
{articles.length > 0 && (
<section class="cat-section" aria-labelledby={`cat-${category.slug}`}>
<div class="container">
<div class="cat-section__header">
<h2 class="section-title" id={`cat-${category.slug}`}>{category.label}</h2>
<a href={`/category/${category.slug}`} class="btn btn--ghost cat-more">More {category.label}</a>
</div>
<div class="cat-grid">
<!-- Lead article -->
<div class="cat-grid__lead">
<ArticleCard article={articles[0]!} size="lg" show_excerpt={true} />
</div>
<!-- Sidebar articles -->
<div class="cat-grid__side">
{articles.slice(1, 4).map(article => (
<ArticleCard article={article} size="sm" show_excerpt={false} />
))}
</div>
</div>
</div>
</section>
)}
<style>
.cat-section {
padding: var(--space-8) 0;
border-top: 1px solid var(--color-border);
}
.cat-section__header {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: var(--space-4);
}
.cat-section__header .section-title { margin-bottom: 0; }
.cat-more { white-space: nowrap; }
.cat-grid {
display: grid;
grid-template-columns: 1fr;
gap: var(--space-4);
margin-top: var(--space-6);
}
@media (min-width: 768px) {
.cat-grid {
grid-template-columns: 2fr 1fr;
gap: var(--space-6);
align-items: start;
}
}
.cat-grid__side {
display: flex;
flex-direction: column;
gap: var(--space-3);
}
</style>
@@ -0,0 +1,270 @@
---
import type { ArticleListItem } from '../../types/index.js';
import { relativeTime } from '../../lib/format.js';
interface Props {
articles: ArticleListItem[];
}
const { articles } = Astro.props;
const [main, ...secondary] = articles;
---
{main && (
<section class="hero-section" aria-label="Featured articles">
<div class="container">
<div class="hero-grid">
<!-- Main hero article -->
<article class="hero-main">
<a href={`/article/${main.slug}`} class="hero-main__image-link" aria-hidden="true" tabindex="-1">
{main.featured_image ? (
<img
src={main.featured_image}
alt={main.featured_image_alt}
class="hero-main__image"
loading="eager"
decoding="async"
fetchpriority="high"
width="860"
height="480"
/>
) : (
<div class="hero-main__image img-placeholder">
<svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" opacity="0.2">
<rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/>
<polyline points="21 15 16 10 5 21"/>
</svg>
</div>
)}
</a>
<div class="hero-main__overlay">
<a href={`/category/${main.category.slug}`} class="badge hero-main__cat">{main.category.name}</a>
<h1 class="hero-main__title">
<a href={`/article/${main.slug}`}>{main.title}</a>
</h1>
<p class="hero-main__excerpt">{main.excerpt}</p>
<div class="hero-main__meta">
<span>{main.author.name}</span>
<span aria-hidden="true">·</span>
<time datetime={main.published_at}>{relativeTime(main.published_at)}</time>
<span aria-hidden="true">·</span>
<span>{main.reading_time} min</span>
</div>
</div>
</article>
<!-- Secondary hero articles -->
{secondary.length > 0 && (
<div class="hero-secondary">
{secondary.slice(0, 2).map(article => (
<article class="hero-secondary__item">
<a href={`/article/${article.slug}`} class="hero-secondary__image-link" aria-hidden="true" tabindex="-1">
{article.featured_image ? (
<img
src={article.featured_image}
alt={article.featured_image_alt}
class="hero-secondary__image"
loading="lazy"
decoding="async"
width="400"
height="200"
/>
) : (
<div class="hero-secondary__image img-placeholder" aria-hidden="true"></div>
)}
</a>
<div class="hero-secondary__body">
<a href={`/category/${article.category.slug}`} class="badge badge--secondary hero-secondary__cat">{article.category.name}</a>
<h3 class="hero-secondary__title">
<a href={`/article/${article.slug}`}>{article.title}</a>
</h3>
<div class="hero-secondary__meta text-xs text-muted">
<time datetime={article.published_at}>{relativeTime(article.published_at)}</time>
<span aria-hidden="true">·</span>
<span>{article.reading_time} min</span>
</div>
</div>
</article>
))}
</div>
)}
</div>
</div>
</section>
)}
<style>
.hero-section {
padding: var(--space-6) 0;
background: var(--color-bg);
}
.hero-grid {
display: grid;
grid-template-columns: 1fr;
gap: var(--space-4);
}
@media (min-width: 1024px) {
.hero-grid {
grid-template-columns: 2fr 1fr;
gap: var(--space-6);
align-items: stretch;
}
}
/* --- Main hero --- */
.hero-main {
position: relative;
border-radius: 12px;
overflow: hidden;
background: var(--color-bg-secondary);
}
.hero-main__image-link {
display: block;
}
.hero-main__image,
.hero-main .img-placeholder {
width: 100%;
aspect-ratio: 16/9;
object-fit: cover;
display: block;
}
.hero-main .img-placeholder {
min-height: 280px;
display: flex;
align-items: center;
justify-content: center;
}
@media (min-width: 1024px) {
.hero-main .img-placeholder,
.hero-main .hero-main__image { height: 100%; aspect-ratio: unset; min-height: 400px; }
}
.hero-main__overlay {
position: absolute;
inset: 0;
top: auto;
background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 60%, transparent 100%);
padding: var(--space-6);
display: flex;
flex-direction: column;
gap: var(--space-3);
}
.hero-main__cat { align-self: flex-start; }
.hero-main__title {
font-size: clamp(1.35rem, 3vw, 2rem);
font-weight: 800;
line-height: 1.2;
color: #fff;
}
.hero-main__title a {
color: #fff;
transition: color var(--transition-fast);
}
.hero-main__title a:hover { color: var(--color-primary); }
.hero-main__excerpt {
font-size: var(--text-sm);
color: rgba(255,255,255,0.8);
line-height: 1.5;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
@media (max-width: 640px) { .hero-main__excerpt { display: none; } }
.hero-main__meta {
display: flex;
gap: var(--space-2);
font-size: var(--text-xs);
color: rgba(255,255,255,0.7);
align-items: center;
flex-wrap: wrap;
}
/* --- Secondary hero --- */
.hero-secondary {
display: flex;
flex-direction: column;
gap: var(--space-4);
}
.hero-secondary__item {
display: flex;
flex-direction: column;
border-radius: 8px;
overflow: hidden;
background: var(--color-bg-card);
border: 1px solid var(--color-border);
transition: box-shadow var(--transition-fast);
flex: 1;
}
.hero-secondary__item:hover {
box-shadow: var(--shadow-md);
}
.hero-secondary__image-link {
display: block;
overflow: hidden;
flex-shrink: 0;
}
.hero-secondary__image,
.hero-secondary .img-placeholder {
width: 100%;
aspect-ratio: 16/7;
object-fit: cover;
display: block;
transition: transform 0.4s ease;
}
.hero-secondary__item:hover .hero-secondary__image {
transform: scale(1.04);
}
.hero-secondary .img-placeholder {
display: flex;
align-items: center;
justify-content: center;
}
.hero-secondary__body {
padding: var(--space-4);
display: flex;
flex-direction: column;
gap: var(--space-2);
flex: 1;
}
.hero-secondary__cat { align-self: flex-start; font-size: 0.65rem; }
.hero-secondary__title {
font-size: var(--text-base);
font-weight: 700;
line-height: 1.3;
flex: 1;
}
.hero-secondary__title a {
color: var(--color-text);
transition: color var(--transition-fast);
}
.hero-secondary__title a:hover { color: var(--color-primary); }
.hero-secondary__meta {
display: flex;
gap: var(--space-2);
align-items: center;
margin-top: auto;
}
</style>
@@ -0,0 +1,57 @@
---
import type { ArticleListItem } from '../../types/index.js';
import ArticleCard from '../shared/ArticleCard.astro';
interface Props {
articles: ArticleListItem[];
title?: string;
show_more_href?: string;
}
const { articles, title = 'Latest News', show_more_href } = Astro.props;
---
<section class="latest-section" aria-labelledby="latest-title">
<div class="container">
<div class="latest-header">
<h2 class="section-title" id="latest-title">{title}</h2>
{show_more_href && (
<a href={show_more_href} class="btn btn--ghost latest-more">View all</a>
)}
</div>
<div class="latest-grid">
{articles.map(article => (
<ArticleCard article={article} size="md" show_excerpt={true} />
))}
</div>
</div>
</section>
<style>
.latest-section {
padding: var(--space-8) 0;
}
.latest-header {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: var(--space-4);
}
.latest-header .section-title { margin-bottom: 0; }
.latest-more { white-space: nowrap; }
.latest-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: var(--space-5);
margin-top: var(--space-6);
}
@media (min-width: 1024px) {
.latest-grid {
grid-template-columns: repeat(4, 1fr);
}
}
</style>
+123
View File
@@ -0,0 +1,123 @@
---
import type { DomainConfig } from '../../types/index.js';
interface Props {
config: DomainConfig;
}
const { config } = Astro.props;
const year = new Date().getFullYear();
---
<footer class="site-footer" role="contentinfo">
<div class="container">
<div class="footer-grid">
<!-- Brand -->
<div class="footer-brand">
<a href="/" class="footer-logo">{config.site_name}</a>
<p class="footer-tagline">{config.tagline}</p>
</div>
<!-- Categories -->
<div class="footer-col">
<h3 class="footer-heading">Categories</h3>
<ul role="list" class="footer-links">
{config.categories.map(cat => (
<li><a href={`/category/${cat.slug}`}>{cat.label}</a></li>
))}
</ul>
</div>
<!-- Info -->
<div class="footer-col">
<h3 class="footer-heading">Info</h3>
<ul role="list" class="footer-links">
<li><a href="/about">About</a></li>
<li><a href="/privacy">Privacy Policy</a></li>
<li><a href="/sitemap.xml">Sitemap</a></li>
</ul>
</div>
</div>
<div class="footer-bottom">
<p>&copy; {year} {config.site_name}. All rights reserved.</p>
</div>
</div>
</footer>
<style>
.site-footer {
background: var(--color-bg-secondary);
border-top: 1px solid var(--color-border);
padding-top: var(--space-12);
padding-bottom: var(--space-8);
margin-top: var(--space-16);
}
.footer-grid {
display: grid;
grid-template-columns: 1fr;
gap: var(--space-8);
margin-bottom: var(--space-8);
}
@media (min-width: 640px) {
.footer-grid {
grid-template-columns: repeat(2, 1fr);
}
}
@media (min-width: 1024px) {
.footer-grid {
grid-template-columns: 2fr 1fr 1fr;
}
}
.footer-logo {
display: inline-block;
font-size: var(--text-xl);
font-weight: 900;
color: var(--color-primary);
margin-bottom: var(--space-3);
text-decoration: none;
}
.footer-tagline {
color: var(--color-text-muted);
font-size: var(--text-sm);
line-height: 1.6;
max-width: 280px;
}
.footer-heading {
font-size: var(--text-sm);
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.08em;
color: var(--color-text-muted);
margin-bottom: var(--space-4);
}
.footer-links {
list-style: none;
display: flex;
flex-direction: column;
gap: var(--space-3);
}
.footer-links a {
font-size: var(--text-sm);
color: var(--color-text);
transition: color var(--transition-fast);
}
.footer-links a:hover {
color: var(--color-primary);
}
.footer-bottom {
padding-top: var(--space-6);
border-top: 1px solid var(--color-border);
text-align: center;
font-size: var(--text-sm);
color: var(--color-text-muted);
}
</style>
+250
View File
@@ -0,0 +1,250 @@
---
import type { DomainConfig } from '../../types/index.js';
interface Props {
config: DomainConfig;
}
const { config } = Astro.props;
const current_path = Astro.url.pathname;
---
<header class="site-header" role="banner">
<div class="header-inner container">
<!-- Skip to content -->
<a href="#main-content" class="skip-link">Skip to content</a>
<!-- Logo -->
<a href="/" class="site-logo" aria-label={`${config.site_name} — home`}>
<span class="site-logo__text">{config.site_name}</span>
</a>
<!-- Desktop nav -->
<nav class="site-nav" aria-label="Main navigation">
<ul class="site-nav__list" role="list">
{config.categories.map(cat => (
<li>
<a
href={`/category/${cat.slug}`}
class:list={['site-nav__link', { 'site-nav__link--active': current_path === `/category/${cat.slug}` }]}
>
{cat.label}
</a>
</li>
))}
</ul>
</nav>
<!-- Actions -->
<div class="header-actions">
<button
class="btn-icon"
data-theme-toggle
aria-label="Toggle dark/light mode"
title="Toggle theme"
>
<svg class="icon-sun" aria-hidden="true" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="4"/><line x1="12" y1="2" x2="12" y2="6"/><line x1="12" y1="18" x2="12" y2="22"/>
<line x1="4.93" y1="4.93" x2="7.76" y2="7.76"/><line x1="16.24" y1="16.24" x2="19.07" y2="19.07"/>
<line x1="2" y1="12" x2="6" y2="12"/><line x1="18" y1="12" x2="22" y2="12"/>
<line x1="4.93" y1="19.07" x2="7.76" y2="16.24"/><line x1="16.24" y1="7.76" x2="19.07" y2="4.93"/>
</svg>
<svg class="icon-moon" aria-hidden="true" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/>
</svg>
</button>
<!-- Mobile menu toggle -->
<button
class="btn-icon btn-menu"
aria-label="Open menu"
aria-expanded="false"
aria-controls="mobile-menu"
>
<svg aria-hidden="true" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="12" x2="21" y2="12"/><line x1="3" y1="18" x2="21" y2="18"/>
</svg>
</button>
</div>
</div>
<!-- Mobile menu -->
<nav
id="mobile-menu"
class="mobile-nav"
aria-label="Mobile navigation"
aria-hidden="true"
>
<ul class="mobile-nav__list" role="list">
<li><a href="/" class:list={['mobile-nav__link', { 'mobile-nav__link--active': current_path === '/' }]}>Home</a></li>
{config.categories.map(cat => (
<li>
<a
href={`/category/${cat.slug}`}
class:list={['mobile-nav__link', { 'mobile-nav__link--active': current_path === `/category/${cat.slug}` }]}
>
{cat.label}
</a>
</li>
))}
</ul>
</nav>
</header>
<style>
.site-header {
position: sticky;
top: 0;
z-index: 100;
background: var(--color-bg);
border-bottom: 1px solid var(--color-border);
box-shadow: var(--shadow-sm);
height: var(--header-height);
}
.header-inner {
display: flex;
align-items: center;
gap: var(--space-4);
height: 100%;
}
.skip-link {
position: absolute;
left: -9999px;
top: var(--space-2);
z-index: 999;
background: var(--color-primary);
color: #fff;
padding: var(--space-2) var(--space-4);
border-radius: 4px;
font-weight: 600;
}
.skip-link:focus { left: var(--space-4); }
.site-logo {
flex-shrink: 0;
text-decoration: none;
}
.site-logo__text {
font-size: var(--text-xl);
font-weight: 900;
color: var(--color-primary);
letter-spacing: -0.5px;
}
.site-nav {
flex: 1;
display: none;
}
@media (min-width: 768px) {
.site-nav { display: block; }
.btn-menu { display: none; }
}
.site-nav__list {
display: flex;
gap: var(--space-1);
list-style: none;
}
.site-nav__link {
display: block;
padding: var(--space-2) var(--space-3);
font-size: var(--text-sm);
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.05em;
color: var(--color-text);
border-radius: 4px;
transition: color var(--transition-fast), background var(--transition-fast);
}
.site-nav__link:hover,
.site-nav__link--active {
color: var(--color-primary);
background: rgba(230, 57, 70, 0.07);
}
.header-actions {
display: flex;
align-items: center;
gap: var(--space-2);
margin-left: auto;
}
.btn-icon {
background: transparent;
border: 1px solid var(--color-border);
border-radius: 6px;
width: 36px;
height: 36px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
color: var(--color-text);
transition: all var(--transition-fast);
}
.btn-icon:hover {
background: var(--color-bg-secondary);
border-color: var(--color-text-muted);
}
/* Show sun in dark mode, moon in light mode */
.icon-moon { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
[data-theme="dark"] .icon-sun { display: none; }
/* Mobile menu */
.mobile-nav {
display: none;
background: var(--color-bg);
border-top: 1px solid var(--color-border);
padding: var(--space-4) var(--space-4) var(--space-6);
}
.mobile-nav[aria-hidden="false"] {
display: block;
}
@media (min-width: 768px) {
.mobile-nav { display: none !important; }
}
.mobile-nav__list {
list-style: none;
display: flex;
flex-direction: column;
gap: var(--space-1);
}
.mobile-nav__link {
display: block;
padding: var(--space-3) var(--space-4);
font-size: var(--text-base);
font-weight: 600;
border-radius: 6px;
color: var(--color-text);
transition: all var(--transition-fast);
}
.mobile-nav__link:hover,
.mobile-nav__link--active {
background: var(--color-bg-secondary);
color: var(--color-primary);
}
</style>
<script>
const btn = document.querySelector('.btn-menu') as HTMLButtonElement | null;
const menu = document.getElementById('mobile-menu');
btn?.addEventListener('click', () => {
const is_open = menu?.getAttribute('aria-hidden') === 'false';
menu?.setAttribute('aria-hidden', is_open ? 'true' : 'false');
btn.setAttribute('aria-expanded', is_open ? 'false' : 'true');
btn.setAttribute('aria-label', is_open ? 'Open menu' : 'Close menu');
});
</script>
@@ -0,0 +1,201 @@
---
import type { ArticleListItem } from '../../types/index.js';
import { relativeTime, truncate } from '../../lib/format.js';
interface Props {
article: ArticleListItem;
size?: 'sm' | 'md' | 'lg';
show_excerpt?: boolean;
}
const { article, size = 'md', show_excerpt = true } = Astro.props;
const is_large = size === 'lg';
const is_small = size === 'sm';
---
<article class:list={['article-card', `article-card--${size}`]}>
<a href={`/article/${article.slug}`} class="article-card__image-link" tabindex="-1" aria-hidden="true">
{article.featured_image ? (
<img
src={article.featured_image}
alt={article.featured_image_alt}
class="article-card__image"
loading="lazy"
decoding="async"
width={is_large ? 800 : is_small ? 200 : 400}
height={is_large ? 450 : is_small ? 130 : 225}
/>
) : (
<div class="article-card__image img-placeholder" aria-hidden="true">
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" opacity="0.3">
<rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/>
<polyline points="21 15 16 10 5 21"/>
</svg>
</div>
)}
{article.is_featured && (
<span class="article-card__badge badge">Featured</span>
)}
</a>
<div class="article-card__body">
<a href={`/category/${article.category.slug}`} class="article-card__category badge badge--secondary">
{article.category.name}
</a>
<h3 class="article-card__title">
<a href={`/article/${article.slug}`} class="article-card__title-link">
{is_small ? truncate(article.title, 72) : article.title}
</a>
</h3>
{show_excerpt && !is_small && (
<p class="article-card__excerpt">{truncate(article.excerpt, 120)}</p>
)}
<footer class="article-card__meta">
<span class="article-card__author">{article.author.name}</span>
<span class="article-card__sep" aria-hidden="true">·</span>
<time datetime={article.published_at} class="article-card__time">
{relativeTime(article.published_at)}
</time>
<span class="article-card__sep" aria-hidden="true">·</span>
<span class="article-card__read">{article.reading_time} min read</span>
</footer>
</div>
</article>
<style>
.article-card {
display: flex;
flex-direction: column;
background: var(--color-bg-card);
border: 1px solid var(--color-border);
border-radius: 8px;
overflow: hidden;
transition: box-shadow var(--transition-fast), transform var(--transition-fast);
height: 100%;
}
.article-card:hover {
box-shadow: var(--shadow-md);
transform: translateY(-2px);
}
.article-card--sm {
flex-direction: row;
}
.article-card__image-link {
position: relative;
display: block;
overflow: hidden;
flex-shrink: 0;
}
.article-card--sm .article-card__image-link {
width: 110px;
}
.article-card--lg .article-card__image-link {
aspect-ratio: 16/9;
}
.article-card--md .article-card__image-link {
aspect-ratio: 16/9;
}
.article-card--sm .article-card__image-link {
width: 110px;
height: 80px;
}
.article-card__image {
width: 100%;
height: 100%;
object-fit: cover;
transition: transform 0.4s ease;
}
.article-card__image-link:hover .article-card__image {
transform: scale(1.04);
}
.img-placeholder {
width: 100%;
height: 100%;
min-height: 140px;
background: var(--color-bg-secondary);
}
.article-card--sm .img-placeholder { min-height: 80px; }
.article-card--lg .img-placeholder { min-height: 280px; }
.article-card__badge {
position: absolute;
top: var(--space-2);
left: var(--space-2);
z-index: 1;
}
.article-card__body {
padding: var(--space-4);
display: flex;
flex-direction: column;
gap: var(--space-2);
flex: 1;
}
.article-card--sm .article-card__body {
padding: var(--space-3);
}
.article-card__category {
align-self: flex-start;
font-size: 0.65rem;
text-decoration: none;
transition: opacity var(--transition-fast);
}
.article-card__category:hover { opacity: 0.8; }
.article-card__title {
font-size: var(--text-base);
font-weight: 700;
line-height: 1.35;
flex: 1;
}
.article-card--lg .article-card__title {
font-size: var(--text-xl);
}
.article-card--sm .article-card__title {
font-size: var(--text-sm);
}
.article-card__title-link {
color: var(--color-text);
transition: color var(--transition-fast);
}
.article-card__title-link:hover {
color: var(--color-primary);
}
.article-card__excerpt {
font-size: var(--text-sm);
color: var(--color-text-muted);
line-height: 1.5;
}
.article-card__meta {
display: flex;
align-items: center;
gap: var(--space-2);
font-size: var(--text-xs);
color: var(--color-text-muted);
flex-wrap: wrap;
margin-top: auto;
}
.article-card__sep { opacity: 0.5; }
</style>
@@ -0,0 +1,106 @@
---
import type { ArticleListItem } from '../../types/index.js';
interface Props {
articles: ArticleListItem[];
}
const { articles } = Astro.props;
---
{articles.length > 0 && (
<div class="trending-bar" role="complementary" aria-label="Trending articles">
<div class="container">
<div class="trending-bar__inner">
<span class="trending-bar__label" aria-hidden="true">
<svg width="14" height="14" viewBox="0 0 24 24" fill="var(--color-primary)" aria-hidden="true">
<path d="M17.66 11.2C17.43 10.9 17.15 10.64 16.89 10.38C16.22 9.78 15.46 9.35 14.82 8.72C13.33 7.26 13 4.85 13.95 3C13 3.23 12.17 3.75 11.46 4.32C8.87 6.4 7.85 10.07 9.07 13.22C9.11 13.32 9.15 13.42 9.15 13.55C9.15 13.77 9 13.97 8.8 14.05C8.57 14.15 8.33 14.09 8.14 13.93C8.08 13.88 8.04 13.83 8 13.76C6.87 12.33 6.69 10.28 7.45 8.64C5.78 10 4.87 12.3 5 14.47C5.06 14.97 5.12 15.47 5.29 15.97C5.43 16.57 5.7 17.17 6 17.7C7.08 19.43 8.95 20.67 10.96 20.92C13.1 21.19 15.39 20.8 17.03 19.32C18.86 17.66 19.5 15 18.56 12.72L18.43 12.46C18.22 12 17.66 11.2 17.66 11.2Z"/>
</svg>
Trending
</span>
<ul class="trending-bar__list" role="list">
{articles.map((article, i) => (
<li class="trending-bar__item">
<span class="trending-bar__num" aria-hidden="true">{i + 1}</span>
<a href={`/article/${article.slug}`} class="trending-bar__link">
{article.title}
</a>
</li>
))}
</ul>
</div>
</div>
</div>
)}
<style>
.trending-bar {
background: var(--color-secondary);
color: #fff;
padding: var(--space-2) 0;
}
.trending-bar__inner {
display: flex;
align-items: center;
gap: var(--space-4);
overflow: hidden;
}
.trending-bar__label {
display: flex;
align-items: center;
gap: var(--space-1);
font-size: var(--text-xs);
font-weight: 800;
text-transform: uppercase;
letter-spacing: 0.08em;
white-space: nowrap;
flex-shrink: 0;
color: #fff;
}
.trending-bar__list {
display: flex;
gap: var(--space-6);
list-style: none;
overflow: hidden;
flex: 1;
}
@media (max-width: 640px) {
.trending-bar__list {
overflow-x: auto;
scrollbar-width: none;
-ms-overflow-style: none;
}
.trending-bar__list::-webkit-scrollbar { display: none; }
}
.trending-bar__item {
display: flex;
align-items: center;
gap: var(--space-2);
flex-shrink: 0;
}
.trending-bar__num {
font-size: var(--text-xs);
font-weight: 900;
color: var(--color-primary);
min-width: 1rem;
}
.trending-bar__link {
font-size: var(--text-xs);
font-weight: 600;
color: rgba(255,255,255,0.85);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 220px;
transition: color var(--transition-fast);
}
.trending-bar__link:hover {
color: #fff;
}
</style>
+105
View File
@@ -0,0 +1,105 @@
---
import '../styles/global.css';
import Header from '../components/layout/Header.astro';
import Footer from '../components/layout/Footer.astro';
import type { DomainConfig } from '../types/index.js';
interface Props {
config: DomainConfig;
title: string;
description?: string;
og_image?: string | null;
og_type?: string;
canonical?: string;
schema?: object;
}
const {
config,
title,
description = config.tagline,
og_image = null,
og_type = 'website',
canonical,
schema,
} = Astro.props;
const full_title = title === config.site_name ? title : `${title} | ${config.site_name}`;
const canonical_url = canonical ?? Astro.url.href;
---
<!doctype html>
<html lang={config.locale.split('-')[0]} data-theme="light">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>{full_title}</title>
<meta name="description" content={description} />
<link rel="canonical" href={canonical_url} />
<!-- Favicon -->
<link rel="icon" type="image/svg+xml" href={config.favicon} />
<!-- Open Graph -->
<meta property="og:type" content={og_type} />
<meta property="og:title" content={full_title} />
<meta property="og:description" content={description} />
<meta property="og:url" content={canonical_url} />
<meta property="og:site_name" content={config.site_name} />
{og_image && <meta property="og:image" content={og_image} />}
{og_image && <meta property="og:image:alt" content={full_title} />}
<!-- Twitter Card -->
<meta name="twitter:card" content={og_image ? 'summary_large_image' : 'summary'} />
<meta name="twitter:title" content={full_title} />
<meta name="twitter:description" content={description} />
{og_image && <meta name="twitter:image" content={og_image} />}
<!-- Theme colour -->
<meta name="theme-color" content={config.primary_color} />
<!-- Structured data -->
{schema && (
<script type="application/ld+json" set:html={JSON.stringify(schema)} />
)}
<!-- Sitemap -->
<link rel="sitemap" href="/sitemap.xml" />
<!-- CSS custom properties injected from domain config -->
<style define:vars={{
'color-primary': config.primary_color,
'color-secondary': config.secondary_color,
'color-accent': config.accent_color,
}}>
:root {
--color-primary: var(--color-primary);
--color-secondary: var(--color-secondary);
--color-accent: var(--color-accent);
}
</style>
</head>
<body>
<Header config={config} />
<main id="main-content" tabindex="-1">
<slot />
</main>
<Footer config={config} />
<!-- Theme toggle script — no flash -->
<script>
const saved = localStorage.getItem('theme');
const preferred = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
const theme = saved ?? preferred;
document.documentElement.setAttribute('data-theme', theme);
document.addEventListener('click', (e) => {
const btn = (e.target as Element).closest('[data-theme-toggle]');
if (!btn) return;
const current = document.documentElement.getAttribute('data-theme');
const next = current === 'dark' ? 'light' : 'dark';
document.documentElement.setAttribute('data-theme', next);
localStorage.setItem('theme', next);
});
</script>
</body>
</html>
+225
View File
@@ -0,0 +1,225 @@
import type {
Article,
ArticleListItem,
Category,
HomepageData,
PaginatedResponse,
} from '../types/index.js';
// SWR cache: in-process Map keyed by URL, value is { data, expires }
interface CacheEntry {
data: unknown;
expires: number;
stale_at: number;
}
const cache = new Map<string, CacheEntry>();
const FRESH_TTL = 60_000; // 60s before stale
const STALE_TTL = 300_000; // 5min before hard expiry
async function fetchWithSWR<T>(url: string): Promise<T> {
const now = Date.now();
const entry = cache.get(url);
if (entry && now < entry.stale_at) {
return entry.data as T;
}
// Revalidate in background if stale but not expired
if (entry && now < entry.expires) {
revalidate(url).catch(() => null);
return entry.data as T;
}
// Blocking fetch (cold or hard-expired)
return revalidate<T>(url);
}
async function revalidate<T>(url: string): Promise<T> {
const res = await fetch(url, {
headers: { Accept: 'application/json' },
});
if (!res.ok) {
throw new Error(`Bridge API ${res.status}: ${url}`);
}
const data: T = await res.json();
cache.set(url, {
data,
stale_at: Date.now() + FRESH_TTL,
expires: Date.now() + STALE_TTL,
});
return data;
}
export class BridgeClient {
private base: string;
constructor(bridge_endpoint: string) {
this.base = bridge_endpoint.replace(/\/$/, '');
}
async getHomepage(): Promise<HomepageData> {
return fetchWithSWR<HomepageData>(`${this.base}/homepage`);
}
async getArticles(params: {
category?: string;
page?: number;
per_page?: number;
search?: string;
} = {}): Promise<PaginatedResponse<ArticleListItem>> {
const qs = new URLSearchParams();
if (params.category) qs.set('category', params.category);
if (params.page) qs.set('page', String(params.page));
if (params.per_page) qs.set('per_page', String(params.per_page));
if (params.search) qs.set('search', params.search);
const url = `${this.base}/articles?${qs.toString()}`;
return fetchWithSWR<PaginatedResponse<ArticleListItem>>(url);
}
async getArticle(slug: string): Promise<Article> {
return fetchWithSWR<Article>(`${this.base}/articles/${slug}`);
}
async getCategories(): Promise<Category[]> {
return fetchWithSWR<Category[]>(`${this.base}/categories`);
}
async getCategory(slug: string): Promise<Category> {
return fetchWithSWR<Category>(`${this.base}/categories/${slug}`);
}
async getTrending(limit = 5): Promise<ArticleListItem[]> {
return fetchWithSWR<ArticleListItem[]>(`${this.base}/trending?limit=${limit}`);
}
async getRelated(slug: string, limit = 4): Promise<ArticleListItem[]> {
return fetchWithSWR<ArticleListItem[]>(`${this.base}/articles/${slug}/related?limit=${limit}`);
}
}
// Stub/mock for development when bridge is not running
export class MockBridgeClient extends BridgeClient {
constructor() {
super('http://localhost:3200');
}
override async getHomepage(): Promise<HomepageData> {
return {
hero: this.mockArticles(3, true, false),
trending: this.mockArticles(5, false, true),
featured: this.mockArticles(4, true, false),
latest: this.mockArticles(12),
by_category: {
football: this.mockArticles(4),
basketball: this.mockArticles(4),
formula1: this.mockArticles(4),
},
};
}
override async getArticles(params: {
category?: string;
page?: number;
per_page?: number;
} = {}): Promise<PaginatedResponse<ArticleListItem>> {
const per_page = params.per_page ?? 12;
const page = params.page ?? 1;
const items = this.mockArticles(per_page, false, false, params.category);
return { items, total: 48, page, per_page, total_pages: Math.ceil(48 / per_page) };
}
override async getArticle(slug: string): Promise<Article> {
const base = this.mockArticleItem(1, slug);
return {
...base,
updated_at: base.published_at,
content: this.mockContent(),
tags: [
{ id: 1, slug: 'champions-league', name: 'Champions League' },
{ id: 2, slug: 'transfer', name: 'Transfer' },
],
is_featured: true,
is_trending: true,
};
}
override async getCategories(): Promise<import('../types/index.js').Category[]> {
return [
{ id: 1, slug: 'football', name: 'Football', description: 'Football news', count: 120 },
{ id: 2, slug: 'basketball', name: 'Basketball', description: 'Basketball news', count: 48 },
{ id: 3, slug: 'formula1', name: 'Formula 1', description: 'F1 news', count: 36 },
{ id: 4, slug: 'tennis', name: 'Tennis', description: 'Tennis news', count: 24 },
{ id: 5, slug: 'mma', name: 'MMA', description: 'MMA news', count: 18 },
];
}
override async getCategory(slug: string): Promise<import('../types/index.js').Category> {
return { id: 1, slug, name: slug.charAt(0).toUpperCase() + slug.slice(1), description: `${slug} news`, count: 48 };
}
override async getTrending(limit = 5): Promise<ArticleListItem[]> {
return this.mockArticles(limit, false, true);
}
override async getRelated(slug: string, limit = 4): Promise<ArticleListItem[]> {
return this.mockArticles(limit);
}
private mockArticleItem(id: number, slug?: string): ArticleListItem {
const slugs = ['football', 'basketball', 'formula1', 'tennis'];
const cat_slug = slugs[id % slugs.length] ?? 'football';
const titles = [
'Manchester United Signs New Star Forward in Record Deal',
'Real Madrid Dominate Champions League Group Stage',
'Verstappen Claims Pole Position in Dramatic Qualifying',
'Djokovic Wins Fifth Consecutive Grand Slam',
'LeBron James Scores Triple-Double in Season Opener',
'Arsenal Extend Premier League Lead with Late Winner',
'Hamilton Sets Lap Record at Monza Circuit',
'Nadal Returns from Injury with Impressive Comeback',
'Barcelona Secure Top Spot in La Liga Standings',
'McLaren Announce Exciting Engine Partnership Deal',
];
return {
id,
slug: slug ?? `article-${id}`,
title: titles[id % titles.length] ?? `Sports Article ${id}`,
excerpt: 'Breaking news from the world of sports. Our correspondents bring you the latest updates and in-depth analysis from your favourite sports.',
featured_image: null,
featured_image_alt: 'Sports article image',
author: { id: 1, name: 'João Silva', slug: 'joao-silva', avatar: null },
category: { id: id % 5 + 1, slug: cat_slug, name: cat_slug.charAt(0).toUpperCase() + cat_slug.slice(1), description: '', count: 0 },
published_at: new Date(Date.now() - id * 3_600_000).toISOString(),
reading_time: 3 + (id % 5),
is_featured: id < 4,
is_trending: id < 6,
};
}
private mockArticles(count: number, is_featured = false, is_trending = false, category?: string): ArticleListItem[] {
return Array.from({ length: count }, (_, i) => ({
...this.mockArticleItem(i + 1),
is_featured,
is_trending,
...(category ? { category: { id: 1, slug: category, name: category.charAt(0).toUpperCase() + category.slice(1), description: '', count: 0 } } : {}),
}));
}
private mockContent(): string {
return `<p>The match kicked off at the Estadio Santiago Bernabeu under floodlights on a crisp Tuesday evening. Both teams entered the pitch with their full-strength squads, aware that nothing less than victory would do.</p>
<p>From the first whistle, the home side pressed high and looked to exploit any weakness in the opposition's defensive structure. The midfield battle was intense, with both teams fighting for every ball across the pitch.</p>
<p>The opening goal came in the 23rd minute through a stunning long-range effort that left the goalkeeper rooted to the spot. The crowd erupted as the ball nestled in the top corner.</p>
<h2>Second Half Action</h2>
<p>The second half saw the visitors come out with renewed purpose. Their manager had clearly made adjustments at half time, and it showed in the way they controlled possession in the early stages of the half.</p>
<p>The equalizer arrived in controversial fashion when a penalty was awarded after a lengthy VAR review. The resulting spot-kick was dispatched with confidence, sending the goalkeeper the wrong way.</p>
<p>With ten minutes remaining, the decisive goal came from a set-piece situation that had been clearly practiced on the training ground. The result sends one team into the next round while the other faces an anxious wait to see if they can qualify through another route.</p>`;
}
}
+49
View File
@@ -0,0 +1,49 @@
import type { DomainConfig } from '../types/index.js';
import { readFileSync, existsSync } from 'node:fs';
import { resolve, join } from 'node:path';
// Config directory is relative to the monorepo root (two levels up from frontend/)
const CONFIG_DIR = resolve(import.meta.dirname ?? '', '../../../config/domains');
export function getDomainConfig(host: string): DomainConfig {
// Strip port if present
const hostname = host.split(':')[0] ?? 'localhost';
const candidates = [
join(CONFIG_DIR, `${hostname}.json`),
join(CONFIG_DIR, 'localhost.json'),
];
for (const config_path of candidates) {
if (existsSync(config_path)) {
try {
const raw = readFileSync(config_path, 'utf-8');
return JSON.parse(raw) as DomainConfig;
} catch {
// Malformed config - fall through to next candidate
}
}
}
// Minimal fallback so the site doesn't crash during early development
return {
site_name: 'Sports News',
tagline: 'Latest sports news',
theme: 'sports',
logo: '/assets/logo.svg',
favicon: '/favicon.svg',
primary_color: '#e63946',
secondary_color: '#1d3557',
accent_color: '#f1faee',
categories: [
{ slug: 'football', label: 'Football' },
{ slug: 'basketball', label: 'Basketball' },
],
bridge_endpoint: 'http://localhost:3200',
wp_endpoint: 'http://localhost:8080/wp-json',
locale: 'en-US',
timezone: 'Europe/Lisbon',
ads_enabled: false,
analytics_id: null,
};
}
+41
View File
@@ -0,0 +1,41 @@
export function formatDate(iso: string, locale = 'en-US'): string {
const d = new Date(iso);
if (isNaN(d.getTime())) return iso;
return new Intl.DateTimeFormat(locale, {
year: 'numeric',
month: 'long',
day: 'numeric',
}).format(d);
}
export function formatDateShort(iso: string, locale = 'en-US'): string {
const d = new Date(iso);
if (isNaN(d.getTime())) return iso;
return new Intl.DateTimeFormat(locale, {
month: 'short',
day: 'numeric',
}).format(d);
}
export function relativeTime(iso: string): string {
const now = Date.now();
const parsed = new Date(iso);
if (isNaN(parsed.getTime())) return iso;
const then = parsed.getTime();
const diff = (now - then) / 1000;
if (diff < 60) return 'Just now';
if (diff < 3600) return `${Math.floor(diff / 60)}m ago`;
if (diff < 86400) return `${Math.floor(diff / 3600)}h ago`;
if (diff < 604800) return `${Math.floor(diff / 86400)}d ago`;
return formatDateShort(iso);
}
export function truncate(str: string, max: number): string {
if (str.length <= max) return str;
return str.slice(0, max).trimEnd() + '…';
}
export function slugToTitle(slug: string): string {
return slug.replace(/-/g, ' ').replace(/\b\w/g, c => c.toUpperCase());
}
+201
View File
@@ -0,0 +1,201 @@
---
import Base from '../../layouts/Base.astro';
import ArticleHeader from '../../components/article/ArticleHeader.astro';
import RelatedArticles from '../../components/article/RelatedArticles.astro';
import { getDomainConfig } from '../../lib/domain.js';
import { BridgeClient, MockBridgeClient } from '../../lib/bridge.js';
import { formatDate } from '../../lib/format.js';
const { slug } = Astro.params;
if (!slug) return Astro.redirect('/');
const host = Astro.request.headers.get('host') ?? 'localhost';
const config = getDomainConfig(host);
let bridge: BridgeClient;
try {
bridge = new BridgeClient(config.bridge_endpoint);
await fetch(`${config.bridge_endpoint}/health`, { signal: AbortSignal.timeout(2000) });
} catch {
bridge = new MockBridgeClient();
}
let article;
let related;
try {
[article, related] = await Promise.all([
bridge.getArticle(slug),
bridge.getRelated(slug, 4),
]);
} catch {
return Astro.redirect('/');
}
const canonical = `${Astro.url.origin}/article/${slug}`;
const news_article_schema = {
'@context': 'https://schema.org',
'@type': 'NewsArticle',
headline: article.title,
description: article.excerpt,
image: article.featured_image ? [article.featured_image] : [],
datePublished: article.published_at,
dateModified: article.updated_at,
author: {
'@type': 'Person',
name: article.author.name,
url: `${Astro.url.origin}/author/${article.author.slug}`,
},
publisher: {
'@type': 'Organization',
name: config.site_name,
logo: {
'@type': 'ImageObject',
url: `${Astro.url.origin}${config.logo}`,
},
},
mainEntityOfPage: {
'@type': 'WebPage',
'@id': canonical,
},
articleSection: article.category.name,
keywords: article.tags.map(t => t.name).join(', '),
};
const breadcrumb_schema = {
'@context': 'https://schema.org',
'@type': 'BreadcrumbList',
itemListElement: [
{ '@type': 'ListItem', position: 1, name: 'Home', item: Astro.url.origin },
{ '@type': 'ListItem', position: 2, name: article.category.name, item: `${Astro.url.origin}/category/${article.category.slug}` },
{ '@type': 'ListItem', position: 3, name: article.title, item: canonical },
],
};
---
<Base
config={config}
title={article.title}
description={article.excerpt}
og_image={article.featured_image}
og_type="article"
canonical={canonical}
schema={news_article_schema}
>
<!-- Additional schema for breadcrumbs -->
<script type="application/ld+json" set:html={JSON.stringify(breadcrumb_schema)} slot="head" />
<div class="article-page container">
<div class="article-layout">
<!-- Main article column -->
<div class="article-main">
<ArticleHeader article={article} />
<!-- Featured image -->
{article.featured_image && (
<figure class="article-figure">
<img
src={article.featured_image}
alt={article.featured_image_alt}
class="article-figure__img"
loading="eager"
decoding="async"
fetchpriority="high"
width="860"
height="480"
/>
</figure>
)}
<!-- Ad slot: top of article -->
{config.ads_enabled && (
<div class="ad-slot ad-slot--in-article" aria-label="Advertisement">Advertisement</div>
)}
<!-- Article body -->
<div class="article-body" set:html={article.content} />
<!-- Tags -->
{article.tags.length > 0 && (
<div class="article-tags">
<span class="article-tags__label">Tags:</span>
{article.tags.map(tag => (
<span class="badge badge--muted">{tag.name}</span>
))}
</div>
)}
</div>
<!-- Sidebar -->
<aside class="article-sidebar" aria-label="Article sidebar">
{config.ads_enabled && (
<div class="ad-slot ad-slot--sidebar sticky-top" aria-label="Advertisement">Advertisement</div>
)}
</aside>
</div>
<!-- Related articles -->
<RelatedArticles articles={related} />
</div>
</Base>
<style>
.article-page {
padding-top: var(--space-6);
padding-bottom: var(--space-12);
}
.article-layout {
display: grid;
grid-template-columns: 1fr;
gap: var(--space-8);
}
@media (min-width: 1024px) {
.article-layout {
grid-template-columns: minmax(0, 2.5fr) 280px;
align-items: start;
}
}
.article-figure {
margin-bottom: var(--space-8);
border-radius: 12px;
overflow: hidden;
}
.article-figure__img {
width: 100%;
max-height: 520px;
object-fit: cover;
}
.article-tags {
display: flex;
gap: var(--space-2);
align-items: center;
flex-wrap: wrap;
margin-top: var(--space-8);
padding-top: var(--space-6);
border-top: 1px solid var(--color-border);
}
.article-tags__label {
font-size: var(--text-sm);
font-weight: 600;
color: var(--color-text-muted);
}
.sticky-top {
position: sticky;
top: calc(var(--header-height) + var(--space-4));
}
.article-sidebar {
display: none;
}
@media (min-width: 1024px) {
.article-sidebar { display: block; }
}
</style>
+164
View File
@@ -0,0 +1,164 @@
---
import Base from '../../layouts/Base.astro';
import ArticleCard from '../../components/shared/ArticleCard.astro';
import { getDomainConfig } from '../../lib/domain.js';
import { BridgeClient, MockBridgeClient } from '../../lib/bridge.js';
const { slug } = Astro.params;
if (!slug) return Astro.redirect('/');
const host = Astro.request.headers.get('host') ?? 'localhost';
const config = getDomainConfig(host);
const page = parseInt(Astro.url.searchParams.get('page') ?? '1', 10);
const per_page = 12;
let bridge: BridgeClient;
try {
bridge = new BridgeClient(config.bridge_endpoint);
await fetch(`${config.bridge_endpoint}/health`, { signal: AbortSignal.timeout(2000) });
} catch {
bridge = new MockBridgeClient();
}
let category;
let paginated;
try {
[category, paginated] = await Promise.all([
bridge.getCategory(slug),
bridge.getArticles({ category: slug, page, per_page }),
]);
} catch {
return Astro.redirect('/');
}
const cat_config = config.categories.find(c => c.slug === slug);
const display_name = cat_config?.label ?? category.name;
const total_pages = paginated.total_pages;
const has_prev = page > 1;
const has_next = page < total_pages;
const canonical = `${Astro.url.origin}/category/${slug}${page > 1 ? `?page=${page}` : ''}`;
const breadcrumb_schema = {
'@context': 'https://schema.org',
'@type': 'BreadcrumbList',
itemListElement: [
{ '@type': 'ListItem', position: 1, name: 'Home', item: Astro.url.origin },
{ '@type': 'ListItem', position: 2, name: display_name, item: `${Astro.url.origin}/category/${slug}` },
],
};
---
<Base
config={config}
title={`${display_name} — ${config.site_name}`}
description={category.description || `Latest ${display_name} news`}
canonical={canonical}
schema={breadcrumb_schema}
>
<div class="container">
<!-- Breadcrumb -->
<nav class="breadcrumb" style="padding-top: 1.5rem" aria-label="Breadcrumb">
<a href="/">Home</a>
<span class="breadcrumb__sep" aria-hidden="true">/</span>
<span aria-current="page">{display_name}</span>
</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">
{paginated.total} article{paginated.total !== 1 ? 's' : ''}
{total_pages > 1 && ` — page ${page} of ${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} />
))}
</div>
{paginated.items.length === 0 && (
<p class="empty-state">No articles found in this category yet.</p>
)}
<!-- Pagination -->
{total_pages > 1 && (
<nav class="pagination" aria-label="Pagination">
{has_prev && (
<a
href={`/category/${slug}?page=${page - 1}`}
class="pagination__item"
aria-label="Previous page"
>←</a>
)}
{Array.from({ length: Math.min(total_pages, 7) }, (_, i) => {
const p = i + 1;
return (
<a
href={`/category/${slug}?page=${p}`}
class="pagination__item"
aria-current={p === page ? 'page' : undefined}
>
{p}
</a>
);
})}
{has_next && (
<a
href={`/category/${slug}?page=${page + 1}`}
class="pagination__item"
aria-label="Next page"
>→</a>
)}
</nav>
)}
</div>
</Base>
<style>
.category-header {
padding: var(--space-6) 0 var(--space-8);
border-bottom: 3px solid var(--color-primary);
margin-bottom: var(--space-8);
}
.category-header__title {
font-size: clamp(1.75rem, 4vw, 3rem);
font-weight: 900;
margin-bottom: var(--space-2);
}
.category-header__desc {
font-size: var(--text-base);
color: var(--color-text-muted);
margin-bottom: var(--space-2);
}
.category-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: var(--space-5);
margin-bottom: var(--space-8);
}
@media (min-width: 1024px) {
.category-grid { grid-template-columns: repeat(3, 1fr); }
}
.empty-state {
text-align: center;
padding: var(--space-12);
color: var(--color-text-muted);
font-size: var(--text-lg);
}
</style>
+67
View File
@@ -0,0 +1,67 @@
---
import Base from '../layouts/Base.astro';
import TrendingBar from '../components/shared/TrendingBar.astro';
import HeroSection from '../components/home/HeroSection.astro';
import LatestGrid from '../components/home/LatestGrid.astro';
import CategorySection from '../components/home/CategorySection.astro';
import { getDomainConfig } from '../lib/domain.js';
import { BridgeClient, MockBridgeClient } from '../lib/bridge.js';
const host = Astro.request.headers.get('host') ?? 'localhost';
const config = getDomainConfig(host);
let bridge: BridgeClient;
try {
bridge = new BridgeClient(config.bridge_endpoint);
// Quick health probe — fallback to mock if bridge unreachable
await fetch(`${config.bridge_endpoint}/health`, { signal: AbortSignal.timeout(2000) });
} catch {
bridge = new MockBridgeClient();
}
const homepage = await bridge.getHomepage();
const website_schema = {
'@context': 'https://schema.org',
'@type': 'WebSite',
name: config.site_name,
description: config.tagline,
url: Astro.url.origin,
potentialAction: {
'@type': 'SearchAction',
target: {
'@type': 'EntryPoint',
urlTemplate: `${Astro.url.origin}/search?q={search_term_string}`,
},
'query-input': 'required name=search_term_string',
},
};
---
<Base
config={config}
title={config.site_name}
description={config.tagline}
schema={website_schema}
>
<TrendingBar articles={homepage.trending} />
<HeroSection articles={homepage.hero} />
{config.ads_enabled && (
<div class="container" style="padding-block: 1rem">
<div class="ad-slot ad-slot--leaderboard" aria-label="Advertisement">Advertisement</div>
</div>
)}
<LatestGrid
articles={homepage.latest}
title="Latest News"
show_more_href="/category/all"
/>
{config.categories.filter(cat => homepage.by_category[cat.slug]?.length).map(cat => (
<CategorySection
category={cat}
articles={homepage.by_category[cat.slug] ?? []}
/>
))}
</Base>
+20
View File
@@ -0,0 +1,20 @@
import type { APIRoute } from 'astro';
export const GET: APIRoute = ({ url }) => {
const sitemap_url = `${url.origin}/sitemap.xml`;
const content = `User-agent: *
Allow: /
Disallow: /api/
Sitemap: ${sitemap_url}
`;
return new Response(content, {
status: 200,
headers: {
'Content-Type': 'text/plain; charset=utf-8',
'Cache-Control': 'public, max-age=86400',
},
});
};
+64
View File
@@ -0,0 +1,64 @@
import type { APIRoute } from 'astro';
import { getDomainConfig } from '../lib/domain.js';
import { BridgeClient, MockBridgeClient } from '../lib/bridge.js';
export const GET: APIRoute = async ({ request, url }) => {
const host = request.headers.get('host') ?? 'localhost';
const config = getDomainConfig(host);
const base = url.origin;
let bridge: BridgeClient;
try {
bridge = new BridgeClient(config.bridge_endpoint);
await fetch(`${config.bridge_endpoint}/health`, { signal: AbortSignal.timeout(2000) });
} catch {
bridge = new MockBridgeClient();
}
let articles: { slug: string; updated_at?: string; published_at: string }[] = [];
try {
const result = await bridge.getArticles({ per_page: 1000 });
articles = result.items;
} catch {
// Sitemap still works without articles
}
const now = new Date().toISOString().split('T')[0];
const static_urls = [
{ loc: base, changefreq: 'daily', priority: '1.0', lastmod: now },
...config.categories.map(cat => ({
loc: `${base}/category/${cat.slug}`,
changefreq: 'hourly',
priority: '0.8',
lastmod: now,
})),
];
const article_urls = articles.map(a => ({
loc: `${base}/article/${a.slug}`,
changefreq: 'weekly' as const,
priority: '0.7',
lastmod: (a.updated_at ?? a.published_at).split('T')[0],
}));
const all_urls = [...static_urls, ...article_urls];
const xml = `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${all_urls.map(u => ` <url>
<loc>${u.loc}</loc>
<lastmod>${u.lastmod}</lastmod>
<changefreq>${u.changefreq}</changefreq>
<priority>${u.priority}</priority>
</url>`).join('\n')}
</urlset>`;
return new Response(xml, {
status: 200,
headers: {
'Content-Type': 'application/xml; charset=utf-8',
'Cache-Control': 'public, max-age=3600, stale-while-revalidate=86400',
},
});
};
+396
View File
@@ -0,0 +1,396 @@
/* ================================================================
GLOBAL STYLES — News Platform
Mobile-first, dark/light mode, CSS custom properties
================================================================ */
*, *::before, *::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
:root {
/* Brand colours — overridden per domain via inline CSS variables */
--color-primary: #e63946;
--color-primary-dark: #c1121f;
--color-secondary: #1d3557;
--color-accent: #457b9d;
/* Neutral palette */
--color-bg: #ffffff;
--color-bg-secondary: #f8f9fa;
--color-bg-card: #ffffff;
--color-border: #e9ecef;
--color-text: #212529;
--color-text-muted: #6c757d;
--color-text-inverse: #ffffff;
/* Shadows */
--shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
--shadow-md: 0 4px 12px rgba(0,0,0,0.10);
--shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
/* Typography */
--font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
--font-serif: Georgia, 'Times New Roman', serif;
--font-mono: 'SF Mono', Monaco, 'Cascadia Code', monospace;
--text-xs: 0.75rem;
--text-sm: 0.875rem;
--text-base: 1rem;
--text-lg: 1.125rem;
--text-xl: 1.25rem;
--text-2xl: 1.5rem;
--text-3xl: 1.875rem;
--text-4xl: 2.25rem;
--text-5xl: 3rem;
/* Spacing */
--space-1: 0.25rem;
--space-2: 0.5rem;
--space-3: 0.75rem;
--space-4: 1rem;
--space-5: 1.25rem;
--space-6: 1.5rem;
--space-8: 2rem;
--space-10: 2.5rem;
--space-12: 3rem;
--space-16: 4rem;
/* Layout */
--container-max: 1280px;
--container-pad: 1rem;
/* Animation */
--transition-fast: 150ms ease;
--transition-base: 250ms ease;
/* Header */
--header-height: 64px;
}
/* Dark mode */
[data-theme="dark"] {
--color-bg: #0f1117;
--color-bg-secondary: #1a1d26;
--color-bg-card: #1e2130;
--color-border: #2d3143;
--color-text: #e8eaf0;
--color-text-muted: #8b92a9;
--color-text-inverse: #0f1117;
--shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
--shadow-md: 0 4px 12px rgba(0,0,0,0.4);
--shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
}
html {
font-family: var(--font-sans);
font-size: 16px;
line-height: 1.5;
scroll-behavior: smooth;
-webkit-text-size-adjust: 100%;
}
body {
background-color: var(--color-bg);
color: var(--color-text);
min-height: 100dvh;
transition: background-color var(--transition-base), color var(--transition-base);
}
/* ---- Container ---- */
.container {
width: 100%;
max-width: var(--container-max);
margin-inline: auto;
padding-inline: var(--container-pad);
}
@media (min-width: 640px) {
:root { --container-pad: 1.5rem; }
}
@media (min-width: 1024px) {
:root { --container-pad: 2rem; }
}
/* ---- Typography ---- */
h1, h2, h3, h4, h5, h6 {
font-weight: 700;
line-height: 1.25;
color: var(--color-text);
}
a {
color: inherit;
text-decoration: none;
}
a:hover {
color: var(--color-primary);
}
img {
max-width: 100%;
height: auto;
display: block;
}
/* ---- Utility classes ---- */
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0,0,0,0);
white-space: nowrap;
border: 0;
}
.text-primary { color: var(--color-primary); }
.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.badge {
display: inline-block;
padding: 0.2em 0.65em;
border-radius: 3px;
font-size: var(--text-xs);
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.05em;
background: var(--color-primary);
color: #fff;
}
.badge--secondary {
background: var(--color-secondary);
}
.badge--muted {
background: var(--color-bg-secondary);
color: var(--color-text-muted);
}
/* ---- Cards ---- */
.card {
background: var(--color-bg-card);
border: 1px solid var(--color-border);
border-radius: 8px;
overflow: hidden;
transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}
.card:hover {
box-shadow: var(--shadow-md);
transform: translateY(-2px);
}
/* ---- Article image placeholder ---- */
.img-placeholder {
background: linear-gradient(135deg, var(--color-bg-secondary) 0%, var(--color-border) 100%);
display: flex;
align-items: center;
justify-content: center;
color: var(--color-text-muted);
}
/* ---- Buttons ---- */
.btn {
display: inline-flex;
align-items: center;
gap: var(--space-2);
padding: 0.5rem 1.25rem;
border-radius: 6px;
font-size: var(--text-sm);
font-weight: 600;
cursor: pointer;
border: 2px solid transparent;
transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
text-decoration: none;
}
.btn--primary {
background: var(--color-primary);
color: #fff;
}
.btn--primary:hover {
background: var(--color-primary-dark);
color: #fff;
}
.btn--ghost {
background: transparent;
border-color: var(--color-border);
color: var(--color-text);
}
.btn--ghost:hover {
border-color: var(--color-primary);
color: var(--color-primary);
}
/* ---- Section titles ---- */
.section-title {
font-size: var(--text-2xl);
font-weight: 800;
margin-bottom: var(--space-6);
position: relative;
padding-bottom: var(--space-3);
}
.section-title::after {
content: '';
position: absolute;
left: 0;
bottom: 0;
height: 3px;
width: 48px;
background: var(--color-primary);
border-radius: 2px;
}
/* ---- Pagination ---- */
.pagination {
display: flex;
gap: var(--space-2);
align-items: center;
justify-content: center;
flex-wrap: wrap;
margin-top: var(--space-8);
}
.pagination__item {
display: flex;
align-items: center;
justify-content: center;
width: 40px;
height: 40px;
border-radius: 6px;
font-weight: 600;
font-size: var(--text-sm);
background: var(--color-bg-card);
border: 1px solid var(--color-border);
color: var(--color-text);
transition: all var(--transition-fast);
}
.pagination__item:hover,
.pagination__item[aria-current="page"] {
background: var(--color-primary);
border-color: var(--color-primary);
color: #fff;
}
/* ---- Breadcrumb ---- */
.breadcrumb {
display: flex;
gap: var(--space-2);
align-items: center;
font-size: var(--text-sm);
color: var(--color-text-muted);
flex-wrap: wrap;
}
.breadcrumb__sep {
color: var(--color-border);
}
.breadcrumb a:hover {
color: var(--color-primary);
}
/* ---- Ad slots ---- */
.ad-slot {
background: var(--color-bg-secondary);
border: 2px dashed var(--color-border);
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
color: var(--color-text-muted);
font-size: var(--text-xs);
text-transform: uppercase;
letter-spacing: 0.1em;
}
.ad-slot--leaderboard {
height: 90px;
width: 100%;
}
.ad-slot--sidebar {
min-height: 250px;
width: 100%;
}
.ad-slot--in-article {
height: 250px;
width: 100%;
margin-block: var(--space-6);
}
/* ---- Article content ---- */
.article-body {
font-family: var(--font-serif);
font-size: 1.125rem;
line-height: 1.8;
color: var(--color-text);
}
.article-body h2 {
font-family: var(--font-sans);
font-size: var(--text-2xl);
margin-top: var(--space-8);
margin-bottom: var(--space-4);
}
.article-body h3 {
font-family: var(--font-sans);
font-size: var(--text-xl);
margin-top: var(--space-6);
margin-bottom: var(--space-3);
}
.article-body p {
margin-bottom: var(--space-5);
}
.article-body ul, .article-body ol {
margin-left: var(--space-6);
margin-bottom: var(--space-5);
}
.article-body li {
margin-bottom: var(--space-2);
}
.article-body a {
color: var(--color-primary);
text-decoration: underline;
text-decoration-thickness: 1px;
text-underline-offset: 3px;
}
.article-body blockquote {
border-left: 4px solid var(--color-primary);
padding-left: var(--space-4);
margin: var(--space-6) 0;
font-style: italic;
color: var(--color-text-muted);
}
/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--color-bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }
/* ---- Focus visible ---- */
:focus-visible {
outline: 2px solid var(--color-primary);
outline-offset: 2px;
}
+92
View File
@@ -0,0 +1,92 @@
export interface DomainConfig {
site_name: string;
tagline: string;
theme: string;
logo: string;
favicon: string;
primary_color: string;
secondary_color: string;
accent_color: string;
categories: CategoryConfig[];
bridge_endpoint: string;
wp_endpoint: string;
locale: string;
timezone: string;
ads_enabled: boolean;
analytics_id: string | null;
}
export interface CategoryConfig {
slug: string;
label: string;
}
export interface Article {
id: number;
slug: string;
title: string;
excerpt: string;
content: string;
featured_image: string | null;
featured_image_alt: string;
author: Author;
category: Category;
tags: Tag[];
published_at: string;
updated_at: string;
reading_time: number;
is_featured: boolean;
is_trending: boolean;
}
export interface ArticleListItem {
id: number;
slug: string;
title: string;
excerpt: string;
featured_image: string | null;
featured_image_alt: string;
author: Author;
category: Category;
published_at: string;
reading_time: number;
is_featured: boolean;
is_trending: boolean;
}
export interface Author {
id: number;
name: string;
slug: string;
avatar: string | null;
}
export interface Category {
id: number;
slug: string;
name: string;
description: string;
count: number;
}
export interface Tag {
id: number;
slug: string;
name: string;
}
export interface PaginatedResponse<T> {
items: T[];
total: number;
page: number;
per_page: number;
total_pages: number;
}
export interface HomepageData {
hero: ArticleListItem[];
trending: ArticleListItem[];
featured: ArticleListItem[];
latest: ArticleListItem[];
by_category: Record<string, ArticleListItem[]>;
}
+5
View File
@@ -0,0 +1,5 @@
{
"extends": "astro/tsconfigs/strict",
"include": [".astro/types.d.ts", "**/*"],
"exclude": ["dist"]
}