How to use the next/router.pathname function in next

To help you get started, we’ve selected a few next 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 este / este / components / core / Auth.js View on Github external
function onSuccess(auth) {
    const { token } = auth;
    if (token == null) return;
    setCookie({ token });
    // TODO: Typed useRouter.
    if (Router.query.redirectUrl) {
      Router.replace(Router.query.redirectUrl);
    } else if (props.redirectUrl) {
      // $FlowFixMe Wrong libdef.
      Router.replace(props.redirectUrl);
    } else {
      // $FlowFixMe Wrong libdef.
      Router.replace({
        pathname: Router.pathname,
        query: Router.query,
      });
    }
  }
github styled-components / styled-components-website / components / Nav / SearchWithAlgolia.js View on Github external
useEffect(() => {
    if (process.browser && Router.pathname.startsWith('/docs')) setIsDocs(true);

    if (process.env.NODE_ENV !== 'test') {
      import('docsearch.js').then(mdl => {
        mdl.default({
          apiKey: '79886fb59ad3ebe2002b481cffbbe7cb',
          indexName: 'styled-components',
          inputSelector: '[class^="Search__Input"]',
          debug: true, // Set debug to true if you want to inspect the dropdown
          handleSelected: (input, event, suggestion) => {
            // original handleselect
            requestModalClose();
            input.setVal('');
            window.location.assign(suggestion.url);
          },
        });
      });
github patcito / nextjob / components / search.js View on Github external
search = q => {
    console.log(Router.query);
    Router.push({
      pathname: Router.pathname,
      query: {...Router.query, ...{description: q}},
    });
  };
github BeeDesignLLC / GlutenProject.com / components / SearchBoss.js View on Github external
componentDidMount() {
    if (!isPresent(this.state.searchState.query) && Router.pathname === '/search') {
      const searchInput = window.document.querySelector('#global-product-search')
      if (searchInput) searchInput.focus()
    }

    if (window.location.host !== 'glutenproject.com') {
      this.setState({production: false})
    }
  }
github patcito / nextjob / pages / showcompany.js View on Github external
moderators: company.Moderators.map(mod => {
        return mod.userEmail;
      }).join(', '),
      industry: {
        value: company.Industry,
        label: company.Industry,
      },
    };
    delete company['Skills'];
    delete company['Perks'];
    delete company['Moderators'];
    let title = `ReactEurope Jobs - ${company.company.name}`;
    let url;
    req
      ? (url = publicRuntimeConfig.host + req.path)
      : (url = publicRuntimeConfig.host + Router.pathname);
    return {
      translations,
      company,
      companyId,
      userInfo,
      lang,
      companiesCount,
      title,
      url,
    };
  }
  constructor(props) {
github Lucifier129 / next-mvc / src / controller.js View on Github external
get location() {
		if (this.isServer) {
			return this.context.location
		} else if (this.isClient) {
			return {
				pathname: Router.pathname,
				query: Router.query,
				raw: Router.asPath
			}
		}
	}
github patcito / nextjob / pages / showjob.js View on Github external
id: jobId,
      userId: userInfo.userId,
    });
    let companiesCount = job.Company_aggregate;
    let title = 'ReactEurope Jobs - ';

    if (job.Job.length > 0) {
      job = job.Job[0];
      title += job.JobTitle + ' at ' + job.Company.name;
    } else {
      job = null;
    }
    let url;
    req
      ? (url = publicRuntimeConfig.host + req.path)
      : (url = publicRuntimeConfig.host + Router.pathname);

    return {
      translations,
      jobId,
      userInfo,
      job,
      lang,
      companiesCount,
      title,
      url,
    };
  }
  constructor(props) {
github graphitejs / server / examples / school / components / Nav.js View on Github external
componentDidMount() {
    const pathname = Router.pathname.toLowerCase();
    this.setState({ pathname });
  }
github ooni / orchestra / frontend / components / session.js View on Github external
redirectIfInvalid () {
    if (this.isValid() === false) {
      Router.push({
        pathname: '/admin/login',
        query: { 'from': Router.pathname}
      })
      return true
    }
    return false
  }
github jaggerwang / react-in-practice / pages / user / detail.js View on Github external
onPageChange = (page, pageSize) => {
    Router.push({
      pathname: Router.pathname,
      query: Object.assign({ ...Router.query }, {
        offset: (page - 1) * pageSize,
      }),
    })
  }