How to use gatsby-link - 10 common examples

To help you get started, we’ve selected a few gatsby-link 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 freeCodeCamp-China / learn / src / auth / index.js View on Github external
if (err) {
          console.log(err);
          return navigateTo('/strange-place');
        }
        if (authResult && authResult.accessToken && authResult.idToken) {
          return (
            this.setSession(authResult)
              .then(user => {
                updateUserSignedIn(true);
                return fetchUserComplete(user);
              })
              // this could be current-challenge
              .then(() => navigateTo('/#'))
          );
        }
        return navigateTo('/strange-place');
      });
    }
github gatsbyjs / gatsby / packages / gatsby / cache-dir / navigation.js View on Github external
const navigate = (to, options = {}) => {
  // Temp hack while awaiting https://github.com/reach/router/issues/119
  if (!options.replace) {
    window.__navigatingToLink = true
  }

  let { pathname } = parsePath(to)
  const redirect = redirectMap[pathname]

  // If we're redirecting, just replace the passed in pathname
  // to the one we want to redirect to.
  if (redirect) {
    to = redirect.toPath
    pathname = parsePath(to).pathname
  }

  // If we had a service worker update, no matter the path, reload window and
  // reset the pathname whitelist
  if (window.___swUpdated) {
    window.location = pathname
    return
  }

  // Start a timer to wait for a second before transitioning and showing a
  // loader in case resources aren't around yet.
  const timeoutId = setTimeout(() => {
    emitter.emit(`onDelayedLoadPageResources`, { pathname })
    apiRunner(`onRouteUpdateDelayed`, {
      location: window.location,
    })
github leveluptuts / fresh / .docz / .cache / navigation.js View on Github external
const navigate = (to, options = {}) => {
  // Temp hack while awaiting https://github.com/reach/router/issues/119
  if (!options.replace) {
    window.__navigatingToLink = true
  }

  let { pathname } = parsePath(to)
  const redirect = redirectMap[pathname]

  // If we're redirecting, just replace the passed in pathname
  // to the one we want to redirect to.
  if (redirect) {
    to = redirect.toPath
    pathname = parsePath(to).pathname
  }

  // If we had a service worker update, no matter the path, reload window and
  // reset the pathname whitelist
  if (window.___swUpdated) {
    window.location = pathname
    return
  }

  // Start a timer to wait for a second before transitioning and showing a
  // loader in case resources aren't around yet.
  const timeoutId = setTimeout(() => {
    emitter.emit(`onDelayedLoadPageResources`, { pathname })
    apiRunner(`onRouteUpdateDelayed`, {
      location: window.location,
    })
github rodrigopivi / aida / typescript / web / components / TrainExample.tsx View on Github external
private trainTestAndSaveModels = async () => {
        const files = [
            withPrefix('/models/dictionary.json'),
            withPrefix('/models/ngram_to_id_dictionary.json'),
            withPrefix('/models/dataset_params.json'),
            withPrefix('/models/dataset_training.json'),
            withPrefix('/models/dataset_testing.json')
        ];
        const jsonFiles = await this.downloadFiles(files);
        const pretrainedNGramVectors = new Map(jsonFiles[0].data);
        const ngramToIdDictionary = jsonFiles[1].data;
        const datasetParams = jsonFiles[2].data;
        const datasetTraining = jsonFiles[3].data;
        const datasetTest = jsonFiles[4].data;
        await this.timeoutInMs(200); // give some time for the state update after the model setup (before the gpu blocks)
        this.setState({
            datasetParams,
            datasetTest,
            datasetTraining,
            embeddingsAndTrainingDatasetLoaded: true,
            ngramToIdDictionary,
            pretrainedNGramVectors
        });
github rodrigopivi / aida / typescript / web / components / TrainExample.tsx View on Github external
private trainTestAndSaveModels = async () => {
        const files = [
            withPrefix('/models/dictionary.json'),
            withPrefix('/models/ngram_to_id_dictionary.json'),
            withPrefix('/models/dataset_params.json'),
            withPrefix('/models/dataset_training.json'),
            withPrefix('/models/dataset_testing.json')
        ];
        const jsonFiles = await this.downloadFiles(files);
        const pretrainedNGramVectors = new Map(jsonFiles[0].data);
        const ngramToIdDictionary = jsonFiles[1].data;
        const datasetParams = jsonFiles[2].data;
        const datasetTraining = jsonFiles[3].data;
        const datasetTest = jsonFiles[4].data;
        await this.timeoutInMs(200); // give some time for the state update after the model setup (before the gpu blocks)
        this.setState({
            datasetParams,
            datasetTest,
            datasetTraining,
            embeddingsAndTrainingDatasetLoaded: true,
            ngramToIdDictionary,
            pretrainedNGramVectors
github patternfly / patternfly-react / packages / patternfly-4 / react-docs / src / layouts / example.js View on Github external
import PropTypes from 'prop-types';
import { withPrefix } from 'gatsby-link';

// This is a gatsby limitation will be fixed in newer version
let globalStyles = require(`!raw-loader!@patternfly/react-core/../dist/styles/base.css`);
globalStyles = globalStyles.replace(/\.\/assets\//g, withPrefix('/assets/'));
const localStyles = require(`!raw-loader!./index.css`);
import { injectGlobal } from 'emotion';

injectGlobal(globalStyles);
injectGlobal(localStyles);

const propTypes = {
  children: PropTypes.func.isRequired
};

const Layout = ({ children }) => children();

Layout.propTypes = propTypes;

export default Layout;
github leveluptuts / fresh / .docz / .cache / navigation.js View on Github external
const navigate = (to, options = {}) => {
  // Temp hack while awaiting https://github.com/reach/router/issues/119
  if (!options.replace) {
    window.__navigatingToLink = true
  }

  let { pathname } = parsePath(to)
  const redirect = redirectMap[pathname]

  // If we're redirecting, just replace the passed in pathname
  // to the one we want to redirect to.
  if (redirect) {
    to = redirect.toPath
    pathname = parsePath(to).pathname
  }

  // If we had a service worker update, no matter the path, reload window and
  // reset the pathname whitelist
  if (window.___swUpdated) {
    window.location = pathname
    return
  }
github gatsbyjs / gatsby / packages / gatsby / cache-dir / navigation.js View on Github external
const navigate = (to, options = {}) => {
  // Temp hack while awaiting https://github.com/reach/router/issues/119
  if (!options.replace) {
    window.__navigatingToLink = true
  }

  let { pathname } = parsePath(to)
  const redirect = redirectMap[pathname]

  // If we're redirecting, just replace the passed in pathname
  // to the one we want to redirect to.
  if (redirect) {
    to = redirect.toPath
    pathname = parsePath(to).pathname
  }

  // If we had a service worker update, no matter the path, reload window and
  // reset the pathname whitelist
  if (window.___swUpdated) {
    window.location = pathname
    return
  }
github caki0915 / gatsby-starter-redux / src / components / Drawer / index.js View on Github external
onClick={() => {
          navigateTo(withPrefix(item.url));
          toggleDrawer(false);
        }}
      >
github Financial-Times / x-dash / tools / x-docs / src / templates / story.js View on Github external
const formatStorybookUrl = ({componentName, componentStory}) => withPrefix(
	url.format({
		pathname: '/storybook/index.html',
		query: {
			selectedKind: componentName,
			selectedStory: componentStory,
		},
	})
);

gatsby-link

An enhanced Link component for Gatsby sites with support for resource prefetching

MIT
Latest version published 1 day ago

Package Health Score

92 / 100
Full package analysis