vinicius73 / vuepress-plugin-merge-pages

VuePress Plugin: Merge markdown files in a single markdown

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

License:MIT License


Languages

Language:JavaScript 100.0%