Harden CMS security, fix SEO/a11y gaps, and fill in missing article images
CI / build (push) Has been cancelled

Server: refuse to start in production with the default admin password,
drop SVG from the upload allow-list (stored-XSS risk), add baseline
security headers, make the login rate limiter proxy-aware via TRUST_PROXY,
and auto-load .env.local/.env in dev.

Admin: sanitise post bodies on content import/snapshot restore (previously
bypassed sanitiseBody), confirm before discarding a draft, drop back to the
login screen on a mid-session 401 instead of a stuck error, add hero-image
alt text and a title/excerpt search to the articles panel.

Site: replace the soft-404-to-homepage fallback with a real noindex 404
page, add a focus trap/Escape handling/aria-modal to the enquiry modal,
aria-expanded on the mobile nav toggle, ItemList/breadcrumb structured data
for the newsroom and articles, and wire sitemap generation into the build
so it can't go stale. Extract the duplicated NewsGrid/ArticlePage card
markup into a shared PostCard component.

Content: 13 of 18 seed articles shipped with no hero image (one pointed at
a dead WordPress URL); the live blackdice.ai site turned out to still be
the old blackdice-studio.html export, so recovering the originals wasn't
feasible. Filled the gap with freely-licensed Unsplash placeholders,
credited in the author field, until real photography is ready.

Also adds a Gitea Actions CI workflow (typecheck + build).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-13 13:54:38 +05:00
co-authored by Claude Sonnet 5
parent 410463e0ed
commit f02461b456
35 changed files with 477 additions and 146 deletions
+17 -13
View File
@@ -1,8 +1,9 @@
import { useEffect, useMemo } from 'react'
import { useNavigate } from 'react-router-dom'
import { formatPostDate, publishedPosts, useContent } from '../../cms/store'
import { applyJsonLd, applyMeta, articleJsonLd } from '../../cms/seo'
import { categoryMeta, splitAuthor } from './NewsGrid'
import { applyJsonLd, applyMeta, articleJsonLd, breadcrumbJsonLd } from '../../cms/seo'
import { categoryMeta, splitAuthor } from './blogHelpers'
import PostCard from './PostCard'
import type { Post, SiteContent } from '../../cms/types'
/**
@@ -55,7 +56,18 @@ export default function ArticlePage({
siteUrl: content.settings.siteUrl,
robots: post.status === 'draft' ? 'noindex, nofollow' : 'index, follow',
})
applyJsonLd(post.status === 'draft' ? null : articleJsonLd(post, content.settings.siteUrl))
applyJsonLd(
post.status === 'draft'
? null
: [
breadcrumbJsonLd([
{ name: 'Home', url: content.settings.siteUrl },
{ name: 'News', url: `${content.settings.siteUrl}/news` },
{ name: post.title, url: `${content.settings.siteUrl}/blog/${post.slug}` },
]),
articleJsonLd(post, content.settings.siteUrl),
],
)
}, [post, slug, content.settings.siteUrl, suppressMeta])
if (!post) {
@@ -104,7 +116,7 @@ export default function ArticlePage({
<div className="bd-si bd-article-wrap">
{post.hero ? (
<figure className="bd-article-hero-img">
<img src={post.hero} alt={post.title} />
<img src={post.hero} alt={post.heroAlt || post.title} />
{credit ? <figcaption>{credit}</figcaption> : null}
</figure>
) : null}
@@ -121,15 +133,7 @@ export default function ArticlePage({
</div>
<div className="news-grid">
{related.map((other) => (
<article key={other.id} className="news-card bd-news-card" onClick={() => navigate(`/blog/${other.slug}`)}>
<span className={`news-tag ${categoryMeta(other.category).cls}`}>
{categoryMeta(other.category).label.toUpperCase()}
</span>
<h3>{other.title}</h3>
<p className="bd-news-meta">{formatPostDate(other.date)}</p>
<p>{other.excerpt}</p>
<span className="bd-news-more">Read more →</span>
</article>
<PostCard key={other.id} post={other} onOpen={(p) => navigate(`/blog/${p.slug}`)} />
))}
</div>
</div>
+3 -43
View File
@@ -1,48 +1,8 @@
import { useMemo, useState } from 'react'
import { useNavigate } from 'react-router-dom'
import { POST_CATEGORIES, type Post, type PostCategory, type SiteContent } from '../../cms/types'
import { formatPostDate, publishedPosts, useContent } from '../../cms/store'
export const categoryMeta = (id: string) => POST_CATEGORIES.find((c) => c.id === id) || POST_CATEGORIES[0]
/** Authors are stored as "Paul Hague (Image by … on Unsplash)" — split the credit out. */
export function splitAuthor(author: string) {
const match = /^(.*?)\s*\(([^)]*)\)\s*$/.exec(author || '')
return match ? { name: match[1].trim(), credit: match[2].trim() } : { name: (author || '').trim(), credit: '' }
}
function Card({ post, onOpen }: { post: Post; onOpen: (post: Post) => void }) {
const cat = categoryMeta(post.category)
const { name } = splitAuthor(post.author)
return (
<article
className="news-card bd-news-card"
role="link"
tabIndex={0}
onClick={() => onOpen(post)}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault()
onOpen(post)
}
}}>
{post.hero ? (
<div className="bd-news-thumb">
<img src={post.hero} alt="" loading="lazy" />
</div>
) : null}
<span className={`news-tag ${cat.cls}`}>{cat.label.toUpperCase()}</span>
{post.status === 'draft' ? <span className="bd-news-draft">DRAFT</span> : null}
<h3>{post.title}</h3>
<p className="bd-news-meta">
{formatPostDate(post.date)}
{name ? ` · ${name}` : ''}
</p>
<p>{post.excerpt}</p>
<span className="bd-news-more">Read more →</span>
</article>
)
}
import { publishedPosts, useContent } from '../../cms/store'
import PostCard from './PostCard'
/**
* The newsroom grid (/news) and the home page's latest-three strip. Both read the
@@ -118,7 +78,7 @@ export default function NewsGrid({
<div className="news-grid">
{posts.map((post) => (
<Card key={post.id} post={post} onOpen={open} />
<PostCard key={post.id} post={post} onOpen={open} />
))}
</div>
</>
+37
View File
@@ -0,0 +1,37 @@
import { formatPostDate } from '../../cms/store'
import type { Post } from '../../cms/types'
import { categoryMeta, splitAuthor } from './blogHelpers'
/** A single card in the newsroom grid, the home strip, and an article's "keep reading" list. */
export default function PostCard({ post, onOpen }: { post: Post; onOpen: (post: Post) => void }) {
const cat = categoryMeta(post.category)
const { name } = splitAuthor(post.author)
return (
<article
className="news-card bd-news-card"
role="link"
tabIndex={0}
onClick={() => onOpen(post)}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault()
onOpen(post)
}
}}>
{post.hero ? (
<div className="bd-news-thumb">
<img src={post.hero} alt={post.heroAlt || post.title} loading="lazy" />
</div>
) : null}
<span className={`news-tag ${cat.cls}`}>{cat.label.toUpperCase()}</span>
{post.status === 'draft' ? <span className="bd-news-draft">DRAFT</span> : null}
<h3>{post.title}</h3>
<p className="bd-news-meta">
{formatPostDate(post.date)}
{name ? ` · ${name}` : ''}
</p>
<p>{post.excerpt}</p>
<span className="bd-news-more">Read more →</span>
</article>
)
}
+9
View File
@@ -0,0 +1,9 @@
import { POST_CATEGORIES } from '../../cms/types'
export const categoryMeta = (id: string) => POST_CATEGORIES.find((c) => c.id === id) || POST_CATEGORIES[0]
/** Authors are stored as "Paul Hague (Image by … on Unsplash)" — split the credit out. */
export function splitAuthor(author: string) {
const match = /^(.*?)\s*\(([^)]*)\)\s*$/.exec(author || '')
return match ? { name: match[1].trim(), credit: match[2].trim() } : { name: (author || '').trim(), credit: '' }
}