import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import type { BlogArticle, BlogLocale } from '@/lib/blog/types';
import { articlePath, blogPath, visibleArticles } from '@/lib/blog/data';
import { articleSchema } from '@/lib/blog/metadata';
import { copy, editorialCopy } from '@/lib/blog/translations';
import { guideServices, serviceCopy } from '@/lib/blog/services';
import { localizedPath } from '@/lib/i18n/routes';
export function BlogIndex({ locale }: { locale: BlogLocale }) {
const t = copy[locale];
const e = editorialCopy[locale];
const articles = visibleArticles(locale);
return <>
{t.region}
{t.title}
{t.description}
{articles.map((article, index) =>
0{index + 1}{article.description}
{t.read} ↗
)}
{e.routesTitle}
{e.routesNote}
{e.scroll}
>;
}
export function BlogArticleView({ article }: { article: BlogArticle }) {
const t = copy[article.locale];
const e = editorialCopy[article.locale];
const service = guideServices[article.id];
const conversion = serviceCopy[article.locale];
const markdownLink = ({ href, children }: { href?: string; children?: React.ReactNode }) => {children};
const related = visibleArticles(article.locale).filter(a => article.relatedIds.includes(a.id));
const firstSection = article.body.search(/^## /m);
const opening = firstSection < 0 ? article.body : article.body.slice(0, firstSection);
const body = firstSection < 0 ? '' : article.body.slice(firstSection);
const sections = body.split('\n').flatMap((line, index) => line.startsWith('## ') ? [{ title: line.slice(3), line: index + 1 }] : [])
.map((section, index) => ({ ...section, id: `section-${index + 1}` }));
// Only our typed, repository-owned data is serialized. Escape '<' to prevent script termination.
const schema = JSON.stringify(articleSchema(article)).replace(/
{t.ireland} → {article.destinationLabel}
{article.title}
{article.description}
{t.by} STRATA{t.reviewed}:
{opening}
{sections.length > 0 &&
}
section.line === node?.position?.start.line)?.id} tabIndex={-1}>{children}
,
table: ({ children }) => <>{e.scroll}
{e.preparation}{children}
>,
th: ({ children }) => {children} | ,
}}>{body}
{service && }
{related.length > 0 && }
>;
}