How to use the react-static/node.normalizeRoutes function in react-static

To help you get started, we’ve selected a few react-static 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 react-tools / react-smackdown / www / static.config.js View on Github external
function menuToRoutes (items) {
  // Normalize the routes with react-static's normalizer. Make sure it still returns
  // a tree, so we can use it as the sidebar structure. This will also
  // give us routes with full paths at each nesting level we can use in the menu
  const normalizedRoutes = normalizeRoutes(items, {
    tree: true,
    force404: false,
    disableDuplicateRoutesWarning: true,
  })

  // Now we need to use the title, markdown and component info to set up the right
  // components and routeData
  const mapWithComponentsAndData = items =>
    items.map(({
      path, originalPath, component, markdownSrc, title, children = [], ...rest
    }) => ({
      ...rest,
      fullPath: path,
      title,
      path: originalPath,
      component: