<commit_before>import React from "react"
import PropTypes from "prop-types"
import { graphql, Link, navigate } from "gatsby"
import queryString from "query-string"

class Dev404Page extends React.Component {
  static propTypes = {
    data: PropTypes.object,
    custom404: PropTypes.element,
    location: PropTypes.object,
  }

  constructor(props) {
    super(props)
    const { data, location } = this.props
    const pagePaths = data.allSitePage.nodes.map(node => node.path)
    const urlState = queryString.parse(location.search)

    const initialPagePathSearchTerms = urlState.filter ? urlState.filter : ``

    this.state = {
      hasMounted: false,
      showCustom404: false,
      initPagePaths: pagePaths,
      pagePathSearchTerms: initialPagePathSearchTerms,
      pagePaths: this.getFilteredPagePaths(
        pagePaths,
        initialPagePathSearchTerms
      ),
    }
    this.showCustom404 = this.showCustom404.bind(this)
    this.handlePagePathSearch = this.handlePagePathSearch.bind(this)
    this.handleSearchTermChange = this.handleSearchTermChange.bind(this)
  }
<commit_msg>feat(gatsby): allow sites to disable the dev 404 page (#32686)<commit_after>import React from "react"
import PropTypes from "prop-types"
import { graphql, Link, navigate } from "gatsby"
import queryString from "query-string"

class Dev404Page extends React.Component {
  static propTypes = {
    data: PropTypes.object,
    custom404: PropTypes.element,
    location: PropTypes.object,
  }

  constructor(props) {
    super(props)
    const { data, location } = this.props
    const pagePaths = data.allSitePage.nodes.map(node => node.path)
    const urlState = queryString.parse(location.search)

    const initialPagePathSearchTerms = urlState.filter ? urlState.filter : ``

    this.state = {
      hasMounted: false,
      showCustom404: process.env.GATSBY_DISABLE_CUSTOM_404 || false,
      initPagePaths: pagePaths,
      pagePathSearchTerms: initialPagePathSearchTerms,
      pagePaths: this.getFilteredPagePaths(
        pagePaths,
        initialPagePathSearchTerms
      ),
    }
    this.showCustom404 = this.showCustom404.bind(this)
    this.handlePagePathSearch = this.handlePagePathSearch.bind(this)
    this.handleSearchTermChange = this.handleSearchTermChange.bind(this)
  }

{'fraction_non_alphanumeric': 0.09075043630017451, 'fraction_numerical': 0.01788830715532286, 'mean_word_length': 3.777083333333333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5937236', 'n_tokens_mistral': 708, 'n_tokens_neox': 679, 'n_words': 142}