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

@gridsome/source-filesystem

v0.6.2

Published

Filesystem source for Gridsome

Downloads

3,038

Readme

@gridsome/source-filesystem

Transform files into content that can be fetched with GraphQL in your components.

Install

  • yarn add @gridsome/source-filesystem
  • npm install @gridsome/source-filesystem

Usage

module.exports = {
  plugins: [
    {
      use: '@gridsome/source-filesystem',
      options: {
        typeName: 'BlogPost',
        path: './content/blog/**/*.md',
      }
    }
  ],
  templates: {
    BlogPost: '/blog/:year/:month/:day/:slug'
  }
}

A filesystem source will also require a transformer in order to parse the files. The example above is looking for a set of Markdown files, so in order to let Gridsome understand the content of the files, you must install @gridsome/transformer-remark as a dev dependency in your project. Gridsome will automatically transform the files for you as long as a transformer that supports your files is found in your package.json.

Options

path

  • Type: string required

Where to look for files. Should be a glob pattern.

typeName

  • Type: string
  • Default: 'FileNode'

The GraphQL type and template name. A .vue file in src/templates must match the typeName to have a template for it.

baseDir

  • Type: string

The base directory for all files. The baseDir will not be included when routes are generated from the file paths. The option defaults to the project root directory if omitted.

The following example will look for all markdown files inside the /content/blog directory. A file located at /content/blog/hello-world.md will generate a /hello-world route.

module.exports = {
  plugins: [
    {
      use: '@gridsome/source-filesystem',
      options: {
        baseDir: './content/blog',
        path: '*.md'
      }
    }
  ]
}

pathPrefix

  • Type: string

Prefix paths generated from the file location. The example below looks for markdown files inside /content/blog/*.md. And a file named blog-post.md in that folder will get a path like /blog/my-post. This option is excluded if a route is defined.

module.exports = {
  plugins: [
    {
      use: '@gridsome/source-filesystem',
      options: {
        baseDir: './content/blog',
        pathPrefix: '/blog',
        path: '*.md'
      }
    }
  ]
}

refs

  • Type: object

Define fields that will have a reference to another node. The referenced typeName is expected to exist. But a content type can also be created automatically if you set create: true. Read more about references.

module.exports = {
  plugins: [
    {
      use: '@gridsome/source-filesystem',
      options: {
        refs: {
          // Reference to existing authors by id.
          author: 'Author',
          // Create a Tag content type and its nodes automatically.
          tags: {
            typeName: 'Tag',
            create: true
          }
        }
      }
    }
  ]
}

index

  • Type: Array
  • Default: ['index']

Define which files to consider as index files. These files will not have their filename appear in its route path and will become the main index.html file of the directory. Make sure there is only one possible index file per directory if multiple index names are defined. This option is only used if there is no dynamic route defined.