-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathContentPage.tsx
More file actions
31 lines (28 loc) · 1019 Bytes
/
ContentPage.tsx
File metadata and controls
31 lines (28 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import DOMPurify from 'dompurify'
import type { FunctionComponent } from 'react'
import { usePageContext } from 'vike-react/usePageContext'
import type { PageContext } from 'vike/types'
import {
type ContentPages,
type PageContextForContentPage,
useContentPageComponent,
} from './contentPages.tsx'
export const ContentPage: FunctionComponent<{ content: ContentPages }> = ({ content }) => {
const pageContext = usePageContext() as PageContext & PageContextForContentPage
const ContentPageComponent = useContentPageComponent(content, pageContext)
return (
<div>
{ContentPageComponent ? (
<div>
<ContentPageComponent />
</div>
) : pageContext.contentPageHtml ? (
<div
dangerouslySetInnerHTML={{
__html: DOMPurify.sanitize(pageContext.contentPageHtml.toString()),
}}
/>
) : null}
</div>
)
}