Database: - Add missing indexes (users.credits, users_currency(type,amount), users_settings.respects_received, camera_web.timestamp, messenger_offline.user_id) via migrations 0020/0021 - Use partial .select() everywhere instead of SELECT * (tickets, users, rooms, audit logs, catalog tree, polls, radio, password reset) - Add queryPrepared/queryPreparedOne (server-side prepared statements) and switch the login check to a prepared statement; drop dead cache options from the pool config - Raise total_users/total_rooms COUNT(*) cache TTL to 5m Caching: - Consolidate the three cache helpers (cached, redisCache, cachedQuery) into a single memory-first implementation backed by Redis - invalidateKey now clears the in-process cache as well as Redis - Cache homepage sections, news list, and leaderboard tabs; share one news_list cache key between homepage and news archive - siteSettings: in-process cache with TTL so repeated getters no longer pay a Redis round-trip per call - Share a 10s poll cache across all radio SSE connections - Normalize timestamps after cache reads (Redis JSON round-trip) Assets: - Enable AVIF/WebP via images.formats and remove unoptimized from news covers and the homepage hero (149KB jpg) with proper sizes/priority - Support ?format=webp|avif|png in the /imaging proxy via sharp Other: - Fix pnpm supply-chain minimumReleaseAge failures by excluding the freshly-published packages (next 16.3.1, hookform resolvers 5.8.0, resend 6.20.0) - Remove unused before/after fields from housekeeping AuditEntry
109 lines
2.7 KiB
TypeScript
109 lines
2.7 KiB
TypeScript
import Image from "next/image";
|
|
import Link from "next/link";
|
|
import { getTranslations } from "next-intl/server";
|
|
import { ContentCard, EmptyState } from "@/components/public/ui";
|
|
import { excerpt } from "@/lib/format";
|
|
import { formatDate } from "@/lib/format-date";
|
|
import { getNewsList } from "@/lib/services/news-list";
|
|
|
|
export const metadata = { title: "News" };
|
|
|
|
export default async function NewsPage() {
|
|
const t = await getTranslations("pages.news");
|
|
|
|
const articles = await getNewsList(30);
|
|
|
|
return (
|
|
<main style={{ display: "grid", gap: "1.5rem" }}>
|
|
<ContentCard icon="📰" title={t("title")} subtitle={t("subtitle")} />
|
|
|
|
<ContentCard padded={articles.length === 0}>
|
|
{articles.length === 0 ? (
|
|
<EmptyState icon="📰">{t("noArticles")}</EmptyState>
|
|
) : (
|
|
<div className="card-grid sm-2 lg-3" style={{ padding: "1rem" }}>
|
|
{articles.map((a) => (
|
|
<Link
|
|
key={a.slug}
|
|
href={`/news/${a.slug}`}
|
|
className="card hover"
|
|
style={{
|
|
display: "flex",
|
|
flexDirection: "column",
|
|
textDecoration: "none",
|
|
padding: 0,
|
|
overflow: "hidden",
|
|
}}
|
|
>
|
|
{a.image ? (
|
|
<div
|
|
style={{
|
|
position: "relative",
|
|
width: "100%",
|
|
aspectRatio: "16/9",
|
|
}}
|
|
>
|
|
<Image
|
|
src={a.image}
|
|
alt=""
|
|
fill
|
|
sizes="(max-width: 1024px) 50vw, 300px"
|
|
style={{ objectFit: "cover" }}
|
|
/>
|
|
</div>
|
|
) : (
|
|
<div
|
|
style={{
|
|
width: "100%",
|
|
aspectRatio: "16/9",
|
|
backgroundColor:
|
|
"color-mix(in srgb, var(--color-primary) 10%, var(--color-navbar))",
|
|
}}
|
|
/>
|
|
)}
|
|
<div
|
|
style={{
|
|
padding: "1rem 1.1rem",
|
|
flex: 1,
|
|
display: "flex",
|
|
flexDirection: "column",
|
|
}}
|
|
>
|
|
<h3
|
|
style={{
|
|
margin: 0,
|
|
fontSize: "1.05rem",
|
|
color:
|
|
"var(--color-navbar-text-readable, var(--color-navbar-text))",
|
|
lineHeight: 1.4,
|
|
}}
|
|
>
|
|
{a.title}
|
|
</h3>
|
|
<p
|
|
className="muted"
|
|
style={{ margin: "0.35rem 0 0.6rem", fontSize: "0.78rem" }}
|
|
>
|
|
{formatDate(a.createdAt, "date", "")}
|
|
</p>
|
|
<p
|
|
style={{
|
|
margin: 0,
|
|
color:
|
|
"var(--color-navbar-text-readable, var(--color-navbar-text))",
|
|
fontSize: "0.88rem",
|
|
lineHeight: 1.55,
|
|
}}
|
|
>
|
|
{excerpt(a.shortStory, 150)}
|
|
</p>
|
|
</div>
|
|
</Link>
|
|
))}
|
|
</div>
|
|
)}
|
|
</ContentCard>
|
|
</main>
|
|
);
|
|
}
|