gatsby 构建失败,而 github 中的保证金代码

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

尝试将新的更新代码与旧代码合并,但在合并代码时会显示一些“为页面构建静态 html”。我的网站托管在 gatsby 云上,当我在 github 中更新代码时,它也会反映在 gatsby 云上。但是我已经更改了一些登录在代码下面,然后我尝试合并代码但是然后在 github 上创建构建时它失败并出现错误(见屏幕截图)

更新代码 ->

    export function useSideNavState() {
  const data = useStaticQuery(SideNavQuery)
  // eslint-disable-next-line react-hooks/exhaustive-deps
  return React.useMemo(() => {
    let navGroups = groupNodes(data.allMdx.edges.map((edge) => edge.node))
    navGroups.sort(sortGroupsWithConfig(data.site.siteMetadata.sections))
    let newArrr = []
    for (const element of navGroups) {
      for (const ele of element.nodes) {
        if (typeof window !== 'undefined') {
          const allowedElements = [
            'enablex-io-Video',
            'messaging',
            'enablex-io-voice',
            'face-ai',
          ]
          const path = window.location.pathname.split('/')[2]
          if (
            ele.fields.slug.includes(path) &&
            ele.fields.slug.split('/').length >= 5
          ) {
            if (path !== 'quick-start') {
              newArrr.push(element)
            } else if (path === 'quick-start') {
              if (allowedElements.includes(element.name)) {
                newArrr.push(element)
              }
            }
          }
        }
      }
    }
    navGroups = newArrr
    return { navGroups }
  })
}

旧代码 ->

    export function useSideNavState() {
  const data = useStaticQuery(SideNavQuery)
  // eslint-disable-next-line react-hooks/exhaustive-deps
  // console.log(data)
  return React.useMemo(() => {
    let navGroups = groupNodes(data.allMdx.edges.map((edge) => edge.node))
    navGroups.sort(sortGroupsWithConfig(data.site.siteMetadata.sections))
    let newArrr = []
    // console.log(navGroups[4])
    for (const element of navGroups) {
      for (const ele of element.nodes) {
        if (typeof window !== 'undefined') {
          if (
            ele.fields.slug.includes(window.location.pathname) &&
            ele.fields.slug.split('/').length === 5
          ) {
            newArrr.push(element)

            // console.log(element)
          }
        }
      }
    }
    navGroups = newArrr
    return { navGroups }
  }, [data])
}

当我尝试用旧代码更改新代码时,然后构建成功创建。所以我发现问题只出在更新的代码上

error shows in gatsby cloud log

github gatsby mdx
© www.soinside.com 2019 - 2024. All rights reserved.