我试图加载我的反应头盔标签服务器端,以便这些注入静态html文件在构建时。这将允许像Facebook这样的东西直接获取源文件并使用适当的元标记。
使用此方法配置应用程序后,在服务器端静态呈现输出中看到的全部内容是:
<title data-react-helmet="true"></title>设置:
gatsby-config.js
module.exports = {
plugins: ['gatsby-plugin-react-helmet']
}app.tsx
import Helmet from 'react-helmet';
const Head: React.FunctionComponent<Props> = () => (
<Helmet title="the title is big" >
<meta name="description" content="the content" />
</Helmet >
);
...gatsby-ssr.js
const {Helmet} = require('react-helmet');
exports.onRenderBody = () => {
console.log(Helmet.renderStatic())
}
**Output**
<title data-react-helmet="true"></title>有什么想法吗?
发布于 2019-03-06 09:25:28
您不需要拥有自己的gatsby-ssr.js文件。通过使用gatsby-plugin-react-helmet,您就可以出发了。你的头部部件应该能正常工作。
你是怎么看输出的?浏览器中有“查看源”吗?您需要查看一下.html文件夹中的/public文件。
https://stackoverflow.com/questions/55018658
复制相似问题