【发布时间】:2019-10-21 00:44:43
【问题描述】:
如何安全地删除 Gatsby 构建的静态站点中对 Gatsby 的所有引用?
例如,默认的html.js(在.cache/default-html.js中)包含:
import React from "react"
import PropTypes from "prop-types"
export default function HTML(props) {
return (
<html {...props.htmlAttributes}>
<head>
<meta charSet="utf-8" />
<meta httpEquiv="x-ua-compatible" content="ie=edge" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
{props.headComponents}
</head>
<body {...props.bodyAttributes}>
{props.preBodyComponents}
<noscript key="noscript" id="gatsby-noscript">
This app works best with JavaScript enabled.
</noscript>
<div
key={`body`}
id="___gatsby"
dangerouslySetInnerHTML={{ __html: props.body }}
/>
{props.postBodyComponents}
</body>
</html>
)
}
HTML.propTypes = {
htmlAttributes: PropTypes.object,
headComponents: PropTypes.array,
bodyAttributes: PropTypes.object,
preBodyComponents: PropTypes.array,
body: PropTypes.string,
postBodyComponents: PropTypes.array,
}
这会在我每个页面的源代码中产生<div id="___gatsby"><div style="outline:none" tabindex="-1" role="group" id="gatsby-focus-wrapper">。
我想从我所有默认包含的页面中删除字符串 gatsby(而不是我明确添加它的页面 - 例如,我可能会将 <div>This site was built by gatsby</div> 添加到页脚)。
【问题讨论】:
标签: javascript reactjs configuration gatsby