How to use the gatsby.parsePath function in gatsby

To help you get started, we’ve selected a few gatsby examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gatsbyjs / gatsby / packages / gatsby-link / src / index.js View on Github external
onMouseEnter={e => {
          // eslint-disable-line
          onMouseEnter && onMouseEnter(e)
          ___loader.hovering(parsePath(to).pathname)
        }}
        onClick={e => {
github gatsbyjs / gatsby / packages / gatsby-link / src / index.js View on Github external
componentDidUpdate(prevProps, prevState) {
    // Preserve non IO functionality if no support
    if (this.props.to !== prevProps.to && !this.state.IOSupported) {
      ___loader.enqueue(parsePath(this.props.to).pathname)
    }
  }
github gatsbyjs / gatsby / packages / gatsby-link / src / index.js View on Github external
// eslint-disable-line
          onClick && onClick(e)

          if (
            e.button === 0 && // ignore right clicks
            !this.props.target && // let browser handle "target=_blank"
            !e.defaultPrevented && // onClick prevented default
            !e.metaKey && // ignore clicks with modifier keys...
            !e.altKey &&
            !e.ctrlKey &&
            !e.shiftKey
          ) {
            e.preventDefault()
            // Is this link pointing to a hash on the same page? If so,
            // just scroll there.
            const { pathname, hash } = parsePath(prefixedTo)
            if (pathname === location.pathname || !pathname) {
              const element = hash
                ? document.getElementById(hash.substr(1))
                : null
              if (element !== null) {
                element.scrollIntoView()
              } else {
                // This is just a normal link to the current page so let's emulate default
                // browser behavior by scrolling now to the top of the page.
                window.scrollTo(0, 0)
              }
            }

            // Make sure the necessary scripts and data are
            // loaded before continuing.
            navigate(to, { state, replace })
github gatsbyjs / gatsby / packages / gatsby-link / src / index.js View on Github external
componentDidMount() {
    // Preserve non IO functionality if no support
    if (!this.state.IOSupported) {
      ___loader.enqueue(parsePath(this.props.to).pathname)
    }
  }
github gatsbyjs / gatsby / packages / gatsby-link / src / index.js View on Github external
handleIntersection(ref, () => {
        ___loader.enqueue(parsePath(this.props.to).pathname)
      })
    }