1.0.1 • Published 4 years ago

@fejs/route-utils v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

@fejs/route-utils

Usage

# npm
npm i @fejs/route-utils --save

## yarn
yarn add @fejs/route-utils

API

import {
  transformRoute,
  getMatchMenu,
  getMatchMenu,
} from ' @fejs/route-utils';

const routes = [
  {
    path: '/welcome',
    name: 'welcome',
  },
  {
    path: '/admin',
    name: 'admin',
    access: 'canAdmin',
  },
  {
    name: 'list.table-list',
    path: '/list',
  },
];

const { menuData, breadcrumb } = transformRoute(routes);

console.log(menuData[0].name); // welcome

console.log(breadcrumb.get('/welcome').name); // welcome

MenuDataItem

import { MenuDataItem } from '@fejs/route-utils';

export interface MenuDataItem {
  children?: MenuDataItem[];
  hideChildrenInMenu?: boolean;
  hideInMenu?: boolean;
  icon?: React.ReactNode;
  locale?: string | false;
  name?: string;
  key?: string;
  parentKeys?: string[];
  path?: string;
  [key: string]: any;
}

LICENSE

MIT