mirror of
https://github.com/strapi/strapi.git
synced 2025-06-27 00:41:25 +00:00
chore: add json data to dummy preview (#22243)
This commit is contained in:
parent
c91f2b4a2b
commit
3827154d28
@ -22,7 +22,9 @@ module.exports = ({ env }) => ({
|
|||||||
enabled: env.bool('PREVIEW_ENABLED', true),
|
enabled: env.bool('PREVIEW_ENABLED', true),
|
||||||
config: {
|
config: {
|
||||||
handler: (uid, { documentId, locale, status }) => {
|
handler: (uid, { documentId, locale, status }) => {
|
||||||
return `/admin/preview/${uid}/${documentId}/${locale}/${status}`;
|
const kind =
|
||||||
|
strapi.contentType(uid).kind === 'collectionType' ? 'collection-types' : 'single-types';
|
||||||
|
return `/admin/preview/${kind}/${uid}/${documentId}/${locale}/${status}`;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -3,15 +3,22 @@ import { useParams } from 'react-router-dom';
|
|||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { Page, Layouts } from '@strapi/admin/strapi-admin';
|
import { Page, Layouts } from '@strapi/admin/strapi-admin';
|
||||||
import { Grid, Flex, Typography } from '@strapi/design-system';
|
import { unstable_useDocument as useDocument } from '@strapi/content-manager/strapi-admin';
|
||||||
|
import { Grid, Flex, Typography, JSONInput } from '@strapi/design-system';
|
||||||
|
|
||||||
const PreviewComponent = () => {
|
const PreviewComponent = () => {
|
||||||
const { uid, documentId, locale, status } = useParams();
|
const { uid: model, documentId, locale, status, collectionType } = useParams();
|
||||||
|
const { document } = useDocument({
|
||||||
|
model,
|
||||||
|
documentId,
|
||||||
|
params: { locale, status },
|
||||||
|
collectionType,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layouts.Root>
|
<Layouts.Root>
|
||||||
<Page.Main>
|
<Page.Main>
|
||||||
<Page.Title>{`Previewing ${uid}`}</Page.Title>
|
<Page.Title>{`Previewing ${model}`}</Page.Title>
|
||||||
<Layouts.Header title="Static Preview" subtitle="Dummy preview for getstarted app" />
|
<Layouts.Header title="Static Preview" subtitle="Dummy preview for getstarted app" />
|
||||||
<Layouts.Content>
|
<Layouts.Content>
|
||||||
<Flex
|
<Flex
|
||||||
@ -36,7 +43,7 @@ const PreviewComponent = () => {
|
|||||||
Content Type
|
Content Type
|
||||||
</Typography>
|
</Typography>
|
||||||
<Flex gap={3} direction="column" alignItems="start" tag="dd">
|
<Flex gap={3} direction="column" alignItems="start" tag="dd">
|
||||||
<Typography>{uid}</Typography>
|
<Typography>{model}</Typography>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Grid.Item>
|
</Grid.Item>
|
||||||
<Grid.Item col={6} s={12} direction="column" alignItems="start">
|
<Grid.Item col={6} s={12} direction="column" alignItems="start">
|
||||||
@ -62,6 +69,7 @@ const PreviewComponent = () => {
|
|||||||
<Typography tag="dd">{locale}</Typography>
|
<Typography tag="dd">{locale}</Typography>
|
||||||
</Grid.Item>
|
</Grid.Item>
|
||||||
</Grid.Root>
|
</Grid.Root>
|
||||||
|
{document && <JSONInput value={JSON.stringify(document, null, 2)} disabled />}
|
||||||
</Flex>
|
</Flex>
|
||||||
</Layouts.Content>
|
</Layouts.Content>
|
||||||
</Page.Main>
|
</Page.Main>
|
||||||
|
@ -13,7 +13,7 @@ export const registerPreviewRoute = (app) => {
|
|||||||
path: 'preview/*',
|
path: 'preview/*',
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: ':uid/:documentId/:locale/:status',
|
path: ':collectionType/:uid/:documentId/:locale/:status',
|
||||||
element: <Preview />,
|
element: <Preview />,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user