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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user