删除Gatsby的引用

问题描述 投票:0回答:1

如何在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
1个回答
0
投票
可以 customize html.js在核心盖茨比应用程序外部编辑HTML。

但是这可能对您没有帮助,因为它也指出了这一点

在您的<body>内部,您必须有一个ID为___gatsby的div

© www.soinside.com 2019 - 2024. All rights reserved.