Skip to content

MiguelAHM/vuepress-plugin-merge-pages

 
 

Repository files navigation

vuepress-plugin-merge-pages

VuePress Plugin: Merge Markdown files in a single Markdown

NPM NPM Codeclimate Codeclimate lgtm github

Install

yarn add vuepress-plugin-merge-pages -D
npm install vuepress-plugin-merge-pages --save-dev

Usage

module.exports = {
  plugins: [
    [
      'vuepress-plugin-merge-pages',
      {
        bundles: [{
          path: '/printable',
          name: 'print-all-content-page', // optional
          filter: (pages) => { // optional
            return pages.filter(({ path }) => path.includes('/printable-page/'))
          },
          mergePages: pages => { // optional
            const pageBreak = '<hr class="page-break" />\n\n'
            const initialValue = `# My Printable Page\n\n[[TOC]]\n${pageBreak}`
            return pages
              .reduce((acc, current) => {
                return `${acc}${current.content}\n\n${pageBreak}`
              }, initialValue)
          }
        }]
      }
    ]
  ]
}

Options

bundles

  • Type: Array
  • Required: true

List of target merge files.

bundles[].path

  • Type: String
  • Required: false

Page route path, url of target page.

bundles[].name

  • Type: String
  • Required: false

Name of generated file.

bundles[].filter

  • Type: Function => Page[]
  • Required: false

Filter pages of bundle. Receive pages and return new list of pages See above example for mor details

Page object
// page object
{
  content: String,
  path: String,
}

bundles[].mergePages

  • Type: Function => String
  • Required: false

Custom content merge. Allow interaction with pages to inject custom contents. See above example for mor details

About

VuePress Plugin: Merge markdown files in a single markdown

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%