Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

A VuePress plugin to help you generate pages via JSON Schema (HMR ✅)

License

Notifications You must be signed in to change notification settings

vuepress/vuepress-plugin-schema2md

Repository files navigation

vuepress-plugin-schema2md

NPM version NPM downloads Node.js CI

Feature

  • 📄 Generate dynamic VuePress pages from JSON Schemas.
  • ❤️ HMR Support!
  • 🎁 Support extra markdown file to be merged into final content.

Example

Tip. you can execute npm run docs:dev on thie repo to check out this example.

Install

yarn add vuepress-plugin-schema2md  -D 
# OR npm install vuepress-plugin-schema2md -D

Usage

// .vuepress/config.js
module.exports = {
  plugins: [
    [
      'schema2md', {
        // Options
      }
    ]
  ]
}

Options

pages

  • Type: Record<string, ITransformOptions>
  • Description: describe the generated pages.

e.g.

// .vuepress/config.js
module.exports = {
  plugins: ['schema2md', {
    pages: {
      '/config/': {
        schemaPath: '/path/to/your/schema.json'
      }
    }
  }]
}

Then you will get a dynamic page with route /config/, whose content is generated by schema2md from '/path/to/your/schema.json',

For typings of interface ITransformOptions, plead head schema2md.

cwd

  • Type: string
  • Description: Current working directory, used to calcaulate absolute path for "schemaPath" and "outputPath" with relative path, defaults to process.cwd().

locale

  • Type: string
  • Description: Global locale.

write

  • Type: boolean
  • Description: whether to generate the markdown content to disk.

If you want to check out the generated markdown, you could do like this:

 // .vuepress/config.js
 module.exports = {
   plugins: ['schema2md', {
+    write: true,
     pages: {
       '/config/': {
         schemaPath: '/path/to/your/schema.json'
+        outputPath: 'docs/config/README.md', // You shouldn't commit this file.
       }
     }
   }]
 }

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

vuepress-plugin-schema2md © ULIVZ, Released under the MIT License.

github.com/ulivz · GitHub @ULIVZ · Twitter @_ulivz

About

A VuePress plugin to help you generate pages via JSON Schema (HMR ✅)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published