Add articles to the Chayan Asli media outlet page

Implement parsing logic for article content to distinguish between main text and section headers, updating the Article page component and removing an unused API endpoint.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 069d4324-6c40-4355-955e-c714a50de1ea
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/3df548ff-50ae-432f-9be4-25d34eccc983/069d4324-6c40-4355-955e-c714a50de1ea/pIEDxt1
This commit is contained in:
kimjaehyeon0101
2025-09-30 02:46:48 +00:00
parent 1403e6e3c3
commit 36e910112f
4 changed files with 103 additions and 12 deletions

View File

@ -92,6 +92,27 @@ export default function Article() {
placeBetMutation.mutate({ marketId, side, amount });
};
const parseArticleContent = (content: string) => {
const sectionRegex = /##SECTION##(.+?)##/g;
const parts: { type: 'section' | 'text'; content: string }[] = [];
let lastIndex = 0;
let match;
while ((match = sectionRegex.exec(content)) !== null) {
if (match.index > lastIndex) {
parts.push({ type: 'text', content: content.slice(lastIndex, match.index) });
}
parts.push({ type: 'section', content: match[1] });
lastIndex = match.index + match[0].length;
}
if (lastIndex < content.length) {
parts.push({ type: 'text', content: content.slice(lastIndex) });
}
return parts;
};
if (articleLoading) {
return (
<div className="min-h-screen bg-background">
@ -207,10 +228,26 @@ export default function Article() {
)}
<div
className="text-lg leading-relaxed whitespace-pre-wrap"
className="text-lg leading-relaxed"
data-testid="text-article-content"
>
{article.content}
{parseArticleContent(article.content).map((part, index) => {
if (part.type === 'section') {
return (
<h3
key={index}
className="text-2xl font-bold mt-8 mb-4 text-gray-800"
>
{part.content}
</h3>
);
}
return (
<p key={index} className="mb-4 whitespace-pre-wrap">
{part.content}
</p>
);
})}
</div>
</div>
</article>