Skip to content

Commit 53c9107

Browse files
committed
Enable UI shell to render all kinds of child elements
1 parent 8449e29 commit 53c9107

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

packages/anvil-ui-ft-shell/src/components/DocumentHead/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ DocumentHead.defaultProps = {
7676
jsonLd: [],
7777
robots: 'index,follow',
7878
siteTitle: 'Financial Times',
79-
twitterSite: '@FinancialTimes',
79+
twitterSite: '@FinancialTimes'
8080
}
8181

8282
export default DocumentHead

packages/anvil-ui-ft-shell/src/index.tsx

+15-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,21 @@ export default function Shell(props: Props) {
3232
/>
3333
<script dangerouslySetInnerHTML={{ __html: getBootstrapJS() }} />
3434
</head>
35-
<body>{props.children}</body>
35+
{renderComponent(props.children)}
3636
</html>
3737
)
3838
}
39+
40+
function renderComponent(Component) {
41+
if (typeof Component === 'string') {
42+
return <body dangerouslySetInnerHTML={{ __html: Component }} />
43+
} else if (typeof Component === 'function') {
44+
return (
45+
<body>
46+
<Component />
47+
</body>
48+
)
49+
} else {
50+
return <body>{Component}</body>
51+
}
52+
}

0 commit comments

Comments
 (0)