UNPKG

storybook-framework-redwoodjs-vite

Version:

Storybook for RedwoodJS with Vite

22 lines (21 loc) 615 B
import { flattenAll } from "@redwoodjs/router/dist/react-util"; import { isValidRoute } from "@redwoodjs/router/dist/route-validators"; import { replaceParams } from "@redwoodjs/router/dist/util"; export * from "@redwoodjs/router/dist/index"; const routes = {}; const Router = ({ children }) => { const flatChildArray = flattenAll(children); flatChildArray.forEach((child) => { if (isValidRoute(child)) { const { name, path } = child.props; if (name && path) { routes[name] = (args = {}) => replaceParams(path, args); } } }); return null; }; export { Router, routes };