How to use the gatsby.push 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 / examples / gatsbygram / src / components / modal.js View on Github external
previous(e) {
    if (e) {
      e.stopPropagation()
    }
    const currentIndex = this.findCurrentIndex()
    if (currentIndex || currentIndex === 0) {
      let previousPost
      // Wrap around if at start.
      if (currentIndex === 0) {
        previousPost = posts.slice(-1)[0]
      } else {
        previousPost = posts[currentIndex - 1]
      }
      push(`/${previousPost.id}/`)
    }
  }
github gatsbyjs / gatsby / examples / gatsbygram / src / components / modal.js View on Github external
next(e) {
    if (e) {
      e.stopPropagation()
    }
    const currentIndex = this.findCurrentIndex()
    if (currentIndex || currentIndex === 0) {
      let nextPost
      // Wrap around if at end.
      if (currentIndex + 1 === posts.length) {
        nextPost = posts[0]
      } else {
        nextPost = posts[currentIndex + 1]
      }
      push(`/${nextPost.id}/`)
    }
  }
github Bitcoin-com / developer.bitcoin.com / src / templates / docPage.js View on Github external
changeDocs(event: SyntheticEvent) {
    const pageTarget = {
      bitbox: '/bitbox/docs/getting-started',
      badger: '/badger/docs/getting-started',
      gui: '/gui/docs/getting-started',
      rest: '/rest/docs/getting-started',
      slp: '/slp/docs/js/getting-started',
      cashscript: '/cashscript/docs/getting-started',
    }[event.target.value]

    pageTarget && push(pageTarget)
  }