npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sum.cumo/nuxt-custom-route-folder

v2.1.3

Published

Module to automatically add nuxt routes for specified files in the nuxt project.

Downloads

6

Readme

@sum.cumo/nuxt-custom-route-folder

Module to automatically add nuxt routes for specified files in the nuxt project.

install

npm install @sum.cumo/nuxt-custom-route-folder

use within another nuxt module

import createCustomRoutes from '@sum.cumo/nuxt-custom-route-folder'

export default function MyModule() {
  return createCustomRoutes({
    nuxt: this.nuxt,
    glob: 'myCustomFolder/**/*.vue',
  })
}

Given we have a component myCustomFolder/foo.vue, it will be added as a myCustomFolder/foo route to nuxt routes.

configuration

nuxt

When used as a library in another nuxt module, this needs to be the current instance of nuxt

glob

A minimatch pattern specifying all files that should create a new route.

transform(contents, route)

A transformer function that can be used to manipulate or wrap the contents of a file found by the glob.

Its recommended to prefer custom webpack loaders over this config

import createCustomRoutes from '@sum.cumo/nuxt-custom-route-folder'

export default function MyModule() {
  return createCustomRoutes({
    nuxt: this.nuxt,
    glob: 'markdown/**/*.md',
    transform(content) {
      return someMarkdownToVueMagic(content)
    },
  })
}

transformExt

default: 'js'

Specify the file extension with which the result of the transform is being stored. This is especially relevant to control which webpack loaders are applied to the transformed file.

priority

default: 0

When the module is used for different custom folders and multiple routes are created using the same path, the one with a higher priority will take precedence over the one with a lower priority.

mapRouteName(basePath, component)

Customize the name that is created for each generated route.

mapRoutePath(path)

Customize the path of each generated route.

This can be useful when using a different path then the folder name or for prefixing.

filter(component)

Can be used to additionally blacklist components.

Prefer using a more specific glob over this.

srcDir

default: srcDir from nuxt.options

the source directory of the nuxt application, use as a base for the given glob.

watch

default: dev from nuxt.options

whether or not future file changes should cause a rebuild of the routes.