Skip to content

Latest commit

 

History

History
110 lines (81 loc) · 2.42 KB

router.mdx

File metadata and controls

110 lines (81 loc) · 2.42 KB

import { docsUtilsRoutes } from '@pikas/docs-routes'; export const { getLink } = docsUtilsRoutes; import { NextSeo } from 'next-seo';

@pikas-utils/router

This package contains a avatar component.

Change Log

Installation

You can install this package using npm, yarn, or pnpm.

npm install @pikas-utils/router
yarn add @pikas-utils/router
pnpm add @pikas-utils/router

Usage

import { routes } from '@pikas-utils/router';

// Define your routes
const { getLink } = routes({
  origin: 'https://www.google.com',
  links: {
    home: '/',
    about: '/about',
    contact: '/contact',
    items: '/items:id',
    docs: '/docs',
  },
});

Parameters

Prop Description Type Default
origin The origin of the website string required
links The links of the website Record<string, string> required

getLink

getLink('ROUTE_NAME', CONFIG);

Examples

const homeLink = getLink('home');
// => '/'

const aboutLink = getLink('about', {
  withOrigin: true,
});
// => 'https://www.google.com/about'

const itemLink = getLink('items', {
  query: {
    id: '123',
  },
});
// => '/items/123'

const contactLink = getLink('contact', {
  hash: 'MyHash',
});
// => '/contact#MyHash'

const docsLink = getLink('docs', {
  lang: 'en',
});
// => '/en/docs'

Config

Prop Description Type Default
withOrigin The origin of link boolean false
query The query of link Record<string, number or string> -
lang The language of link string -
hash The hash of link string -
keepHash Keep the hash boolean false
keepSearch Keep the search boolean false

Contributing

This documentation can be edited on GitHub here