How to use navi - 10 common examples

To help you get started, we’ve selected a few navi 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 frontarm / navi / packages / navi-scripts / template / src / routes / index.js View on Github external
import { mount, route } from 'navi'

export default mount({
  '/': route({
    title: "React Site",
    getView: () => import('./index.mdx')
  }),
    
  '/getting-started': route({
    title: "Getting Started",
    getView: async () => {
      // This simulates some async content loading, so that
      // you can test the site's loading bar.
      await new Promise(resolve => setTimeout(resolve, 1000))

      return import('./getting-started.mdx')
    }
  }),
})
github frontarm / navi / packages / navi-scripts / template-typescript / src / routes / index.tsx View on Github external
import { map, route, withView } from 'navi'

export default map({
  '/': route({
    title: "React Site",
    getView: () => import('./index.mdx')
  }),
    
  '/getting-started': route({
    title: "Getting Started",
    getView: async () => {
      // This simulates some async content loading, so that
      // you can test the site's loading bar.
      await new Promise(resolve => setTimeout(resolve, 1000))

      return import('./getting-started.mdx')
    }
  }),
})
github frontarm / navi / packages / navi-scripts / template / src / routes / index.js View on Github external
import { mount, route } from 'navi'

export default mount({
  '/': route({
    title: "React Site",
    getView: () => import('./index.mdx')
  }),
    
  '/getting-started': route({
    title: "Getting Started",
    getView: async () => {
      // This simulates some async content loading, so that
      // you can test the site's loading bar.
      await new Promise(resolve => setTimeout(resolve, 1000))

      return import('./getting-started.mdx')
    }
  }),
})
github frontarm / navi / examples / basic-static-rendering / src / routes / index.js View on Github external
import React from 'react'
import { mount, route } from 'navi'

export default mount({
  '/': route({
    title: 'Home',
    head: <>
      
    ,
    getView: () => import('./index.mdx')
  }),
    
  '/about': route({
    title: "About",
    getView: async () => {
      // This simulates some async content loading, so that
      // you can test the site's loading bar.
      await new Promise(resolve => setTimeout(resolve, 1000))

      return import('./about.mdx')
    }
github frontarm / navi / examples / basic / src / routes / index.js View on Github external
import { lazy, mount, route } from 'navi'

const routes = mount({
  '/': route({
    // Add a title to the route, which will be automatically used as
    // the document's `<title>`.
    title: 'Home',
  
    // Define the content which will be rendered in place of the react-navi
    // `&lt;View /&gt;` component. Dynamically import the view, so that it isn't
    // loaded until needed.
    getView: () =&gt; import('./home/view')
  }),
    
  // Dynamically import the entire '/about' route, so that it isn't loaded
  // until needed.
  '/about': lazy(() =&gt; import('./about/route')),
})

export default routes</title>
github frontarm / navi / packages / navi-scripts / template-typescript / src / routes / index.tsx View on Github external
import { map, route, withView } from 'navi'

export default map({
  '/': route({
    title: "React Site",
    getView: () => import('./index.mdx')
  }),
    
  '/getting-started': route({
    title: "Getting Started",
    getView: async () => {
      // This simulates some async content loading, so that
      // you can test the site's loading bar.
      await new Promise(resolve => setTimeout(resolve, 1000))

      return import('./getting-started.mdx')
    }
  }),
})
github frontarm / navi / examples / blog-typescript / src / routes / tags.tsx View on Github external
...context,
      tagsRoot: req.mountpath,
    }),
  ),
  withCrawlerPatterns({
    '/:tag': async (req, context: TagsNavContext) =&gt; {
      if (!context.crawlingRoutes) {
        return getAvailableTagsFromRoutes(
          await crawlRoutes(context.blogRoot),
        ).map(tag =&gt; '/' + tag)
      }
      return []
    },
  }),
  mount({
    '/': route({
      title: 'Tags',

      getView: async (req, context) =&gt; {
        // Build a list of pages for each tag
        let routes = await crawlRoutes(context.blogRoot)
        let tags = getAvailableTagsFromRoutes(routes)
        let tagRoutes = fromPairs(tags.map(name =&gt; [name.toLowerCase(), []]))
        routes.forEach(route =&gt; {
          let data = route.data
          if (data &amp;&amp; data.tags) {
            data.tags.forEach(tag =&gt; {
              tag = tag.toLowerCase()
              if (tagRoutes[tag]) {
                tagRoutes[tag].push(route)
              }
            })
github frontarm / navi / examples / blog / src / routes / index.js View on Github external
// Put posts under "/posts", so that they can be wrapped with a
    // "" that configures MDX and adds a post-specific layout.
    '/posts': compose(
      withView((req, context) =&gt; ),
      mount(fromPairs(posts.map(post =&gt; ['/' + post.slug, post.getPage]))),
    ),

    // Miscellaneous pages can be added directly to the root switch.
    '/tags': lazy(() =&gt; import('./tags')),
    '/about': lazy(() =&gt; import('./about')),

    // Only the statically built copy of the RSS feed is intended to be opened,
    // but the route is defined here so that the static renderer will pick it
    // up.
    '/rss': route(),
  }),
)

export default routes
github frontarm / navi / examples / blog-typescript / src / routes / index.tsx View on Github external
// Put posts under "/posts", so that they can be wrapped with a
    // "" that configures MDX and adds a post-specific layout.
    '/posts': compose(
      withView((req, context: AppNavContext) =&gt; ),
      mount(fromPairs(posts.map(post =&gt; ['/' + post.slug, post.getPage]))),
    ),

    // Miscellaneous pages can be added directly to the root switch.
    '/tags': lazy(() =&gt; import('./tags')),
    '/about': lazy(() =&gt; import('./about')),

    // Only the statically built copy of the RSS feed is intended to be opened,
    // but the route is defined here so that the static renderer will pick it
    // up.
    '/rss': route(),
  }),
)

export default routes
github jamesknelson / create-react-blog / template / src / routes / index.js View on Github external
// "" that configures MDX and adds a post-specific layout.
    '/posts': compose(
      withView((req, context) =&gt; (
        
      )),
      mount(fromPairs(posts.map(post =&gt; ['/' + post.slug, post.getPage]))),
    ),

    // Miscellaneous pages can be added directly to the root switch.
    '/tags': lazy(() =&gt; import('./tags')),
    '/about': lazy(() =&gt; import('./about')),

    // Only the statically built copy of the RSS feed is intended to be opened,
    // but the route is defined here so that the static renderer will pick it
    // up.
    '/rss': route(),
  }),
)

export default routes

navi

A router-loader for React.

MIT
Latest version published 2 years ago

Package Health Score

53 / 100
Full package analysis

Popular navi functions