gatsby-plugin-docs-creator
Gatsby plugin that automatically creates pages from React components in specified directories with additional docs related data
Last updated a month ago by uifrnbot .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install gatsby-plugin-docs-creator 
SYNC missed versions from official npm registry.

gatsby-plugin-docs-creator

Gatsby plugin that automatically creates pages from React components in specified directories. Gatsby includes this plugin automatically in all sites for creating pages from components in src/pages.

You may include another instance of this plugin if you'd like to create additional "pages" directories.

With this plugin, any file that lives in the specified pages folder (e.g. the default src/pages) or subfolders will be expected to export a React Component to generate a Page. The following files are automatically excluded:

  • template-*
  • __tests__/*
  • *.test.jsx?
  • *.spec.jsx?
  • *.d.tsx?
  • *.json
  • *.yaml
  • _*
  • .*

To exclude custom patterns, see Ignoring Specific Files

Install

npm install --save gatsby-plugin-docs-creator

How to use

// gatsby-config.js

module.exports = {
  plugins: [
    // You can have multiple instances of this plugin
    // to create pages from React components in different directories.
    //
    // The following sets up the pattern of having multiple
    // "pages" directories in your project
    {
      resolve: `gatsby-plugin-docs-creator`,
      options: {
        path: `${__dirname}/src/account/pages`,
      },
    },
    {
      resolve: `gatsby-plugin-docs-creator`,
      options: {
        path: `${__dirname}/src/settings/pages`,
      },
    },
  ],
}

Ignoring Specific Files

Shorthand

// The following example will disable the `/blog` index page

// gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `gatsby-plugin-docs-creator`,
      options: {
        path: `${__dirname}/src/indexes/pages`,
        ignore: [`blog.(js|ts)?(x)`],
        // See pattern syntax recognized by micromatch
        // https://www.npmjs.com/package/micromatch#matching-features
      },
    },
  ],
}

NOTE: The above code snippet will only stop the creation of the /blog page, which is defined as a React component. This plugin does not affect programmatically generated pages from the createPagesAPI.

Ignore Options

// The following example will ignore pages using case-insensitive matching

// gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `gatsby-plugin-docs-creator`,
      options: {
        path: `${__dirname}/src/examples/pages`,
        ignore: {
          // Example: Ignore `file.example.js`, `dir/s/file.example.tsx`
          patterns: [`**/*.example.(js|ts)?(x)`],
          // Example: Match both `file.example.js` and `file.EXAMPLE.js`
          options: { nocase: true },
          // See all available micromatch options
          // https://www.npmjs.com/package/micromatch#optionsnocase
        },
      },
    },
  ],
}

Current Tags

  • 2.2.0                                ...           latest (a month ago)

3 Versions

  • 2.2.0                                ...           a month ago
  • 2.1.42                                ...           2 months ago
  • 2.1.41                                ...           2 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 40
Dependencies (11)
Dev Dependencies (2)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |