@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

PropDescriptionTypeDefault
originThe origin of the websitestringrequired
linksThe links of the websiteRecord<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

PropDescriptionTypeDefault
withOriginThe origin of linkbooleanfalse
queryThe query of linkRecord<string, number or string>-
langThe language of linkstring-
hashThe hash of linkstring-
keepHashKeep the hashbooleanfalse
keepSearchKeep the searchbooleanfalse

Contributing

This documentation can be edited on GitHub here