Closed Jiohon closed 1 year ago
目前使用的是这种方式,不知道有更好的方式没有?
export const replaceRenderer = ({ replaceBodyHTMLString, bodyComponent, setHeadComponents }) => {
const html = renderToString(<>{bodyComponent}</>)
const antdCache = (global as any).__ANTD_CACHE__
const styles = extractStaticStyle(html, { antdCache }).map((item) => item.style)
styles.forEach((item) => {
setHeadComponents([
<style
key="emotion"
data-emotion={`acss---`}
dangerouslySetInnerHTML={{
__html: item.props.dangerouslySetInnerHTML.__html,
}}
/>,
])
})
replaceBodyHTMLString(html)
}
🧐 问题描述
请问在Gatsby内如何使用ssr, 是否有类似emotion/ssr的api
💻 示例代码
gatsby-ssr.jsx
🚑 其他信息