Fix admin studio article preview always showing "moved" error

ArticlePage and NewsGrid called useContent() directly, bypassing the
draft content SiteApp resolves for admin previews. Since /admin is
rendered outside ContentProvider, this always returned an empty post
list, so every article in the studio looked unpublished.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-13 12:18:13 +05:00
co-authored by Claude Sonnet 5
parent 63a36e0dca
commit 410463e0ed
3 changed files with 34 additions and 9 deletions
+13 -3
View File
@@ -3,15 +3,25 @@ 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 type { Post } from '../../cms/types'
import type { Post, SiteContent } from '../../cms/types'
/**
* A single article at /blog/<slug>. Rendered into the #pg-article container inside
* the site markup, so it inherits the real nav, footer and enquiry modal — and the
* white-section rule that makes the body copy readable.
*/
export default function ArticlePage({ slug, suppressMeta = false }: { slug: string; suppressMeta?: boolean }) {
const content = useContent()
export default function ArticlePage({
slug,
suppressMeta = false,
content: contentProp,
}: {
slug: string
suppressMeta?: boolean
/** Admin preview: use the editor's draft rather than the published context. */
content?: SiteContent
}) {
const publishedContent = useContent()
const content = contentProp || publishedContent
const navigate = useNavigate()
// Drafts are reachable by direct link so they can be reviewed before going live,