Code Monkey home page Code Monkey logo

vuepress-plugin-export's Introduction

vuepress-plugin-export

NPM version NPM downloads

This plugin requires VuePress >= 1.0.0-alpha.44.

Features

  • Merge all of your pages automatically.

TODO

  • Support default and confurable front cover.
  • Inject Table of Contents.
  • Inject Page Numbers.
  • Generate different PDF files per locale.
  • Transform all of links.

Install

npm i vuepress-plugin-export

Usage

Using this plugin:

// .vuepress/config.js
module.exports = {
  plugins: ['vuepress-plugin-export']
}

Then run:

vuepress export [path/to/your/docs]

Generating multiple output files

You can configure this plugin to export multiple files. Add config options:

module.exports: ['vuepress-plugin-export', {
  theme: '@vuepress/default',
  puppeteer: { args: ['--no-sandbox'] },
  bundles: [{
    filter: (location) => !location.includes('export'),
    dest: () => 'docs/public/export.pdf',
  }, {
    filter: /\/en\///,
    dest: (siteConfig) => `docs/public/${siteConfig.title}.en.pdf`,
  }]
}]

Then run:

vuepress export [path/to/your/docs]

Config options

  • theme: String
  • puppeteer: Object
  • bundles: Array | Function(Array[PageConfig]) => Array[bundle]
  • bundles[].filter: RegExp | Function(location: string, page: PageConfig) => boolean
  • bundles[].dest: (config: VuepressPluginConfig(https://vuepress.vuejs.org/config/#basic-config)) => string
  • bundles[].sorter: Function(PageConfig, PageConfig) => -1, 0, 1

with PageConfig:

url: string
location: string
title: string
path: string

Development

git clone https://github.com/ulivz/vuepress-plugin-export
cd vuepress-plugin-export
yarn
yarn export

Note that this package is powered by puppeteer, if you are in a mysterious wall, consider setting environment variables before installation.

PUPPETEER_DOWNLOAD_HOST=https://npm.taobao.org/mirrors

Note that this pavkage is powered by easy-pdf-merge, Java 6 or higher must be present.

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-export © ULVIZ, Released under the MIT License.
Authored and maintained by ULVIZ with help from contributors (list).

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

vuepress-plugin-export's People

Contributors

chunksnbits avatar sullivanpt avatar ulivz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

vuepress-plugin-export's Issues

when installed from NPM, tarball does not contain last version of code

The issue is that I wanted to sort pages in exported PDF, but code does not work as expected. As a result, pages are not sorted in resulting PDF.

This problem is caused by a version of index.js in the NPM tarball that is different from the version presented on the Github repository. The version provided in the NPM tarball, while being tagged 0.2.0, does NOT feature usage of the sorted optional function.

Evidence of this difference:

As a workaround, I have added a line to overwrite index.js after the installation of the tarball, by fetching the version from GitHub.

$ npm i vuepress-plugin-export
$ cd node_modules/vuepress-plugin-export/
$ rm index.js
$ wget https://raw.githubusercontent.com/ulivz/vuepress-plugin-export/master/index.js

After that change, the plugin can sort pages as expected.

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on Greenkeeper branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet.
We recommend using:

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please click the 'fix repo' button on account.greenkeeper.io.

blank pdf

Hello,
when i run the command, if has generated 21 pages of pdf but it is just empty and the file size is just 14kb.

am i missing something or plugin is still in experimental stage?

Couldn't detect plugin

Hi, when i run the command vuepress export, it shows the below codes and it's not generating pdf... can anyone take a look pls?

wait Extracting site metadata...
tip Apply theme @vuepress/theme-default
warning [vuepress] cannot resolve plugin "export"
tip Apply plugin @vuepress/container (i.e. "@vuepress/plugin-container") ...
tip Apply plugin @vuepress/container (i.e. "@vuepress/plugin-container") ...
tip Apply plugin @vuepress/register-components (i.e. "@vuepress/plugin-register-components") ...
tip Apply plugin @vuepress/active-header-links (i.e. "@vuepress/plugin-active-header-links") ...
tip Apply plugin @vuepress/search (i.e. "@vuepress/plugin-search") ...
tip Apply plugin @vuepress/nprogress (i.e. "@vuepress/plugin-nprogress") ...
tip Apply plugin @vuepress/container (i.e. "@vuepress/plugin-container") ...
tip Apply plugin @vuepress/container (i.e. "@vuepress/plugin-container") ...
tip Apply plugin @vuepress/container (i.e. "@vuepress/plugin-container") ...
Unknown command: export

`easy-pdf-merge` needs a complete Java JDK

The module easy-pdf-merge needs developers to prepare a Java environment with downloading a complete Java JDK. Is there any other solutions to bypass the tedious environment setup?

Thanks for the efforts.

Timeouts and config.js#base

This tool is really cool! Thank you. I ran into a few issues using it that were pretty easy to work-around in my local code. I'm not sure yet how to fix them correctly so no PR today.

First issue, the paths sent to puppeteer don't include the base from my .vuepress/config.js.

 const exportPages = pages.map(page => {
    return {
      url: page.path,
      title: page.title,
      location: `http://${host}:${port}<BASE HERE WITHOUT TRAILING SLASH>${page.path}`,
      path: `${tempDir}/${page.key}.pdf`
    }
  })

Second issue, puppeteer tries to navigate before the build is finished; in my case the build is over a minute, and puppeteer times out waiting for the first page to load. I worked around it by inserting a long await on setTimeout for the first loop iteration. I do see vuepress actually logging a message to console when the build is finally done. If the plug in could event on that, it would be cleaner.

   if (I===0) await SOME LONG TIMEOUT

    await browserPage.goto(
      location,
      { waitUntil: 'networkidle2' }
    )

Third issue, pdfbox.jar PDFMerger requires a JDK. The README should point out this dependency.

Fourth issue, it exports all languages and the page assembly order is pretty random. I worked around by assembling/merging myself.

[feature] config for user to hide nav bar and change margin

Is it possible to add the feature for the user to hide the nav bar and change the margin? Since there are some minor styling differences between the website and PDF version of the docs, e.g. no nav bar, upper and bottom margin, text horizontal overflow wrap, etc.

Thanks for the efforts.

Does not work under windows (ADDRESS_INVALID) + potential fix

Hi,
first of all, thanks for creating this plugin, it's very useful!

I'm having troubles running the pdf export on Windows, though:

> vuepress export docs

wait Extracting site metadata...
(...)
info Start to generate current site to PDF ...
Error: net::ERR_ADDRESS_INVALID at http://0.0.0.0:8080

I was able to patch this locally by changing this line of the plugin:

await generatePDF(ctx, nCtx.devProcess.port, nCtx.devProcess.host)

to

await generatePDF(ctx, nCtx.devProcess.port, 'localhost')

With this change, the PDF export works.
Is there a way to configure the host name with the current release?

Cheers,
Daniel

v0.2.0 is left behind master

I want to use bundles[].sorter, but found it did not work. it seems this feature is not in v0.2.0, why not package a new version? By the way , this plugin is great.

Plugin Loading Issue

After installing Vuepress 1.x and the plugin, trying to run the command leads to the following:

At C:\Users\domin\AppData\Local\Yarn\bin\vuepress.ps1:5 char:13
+     *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
+             ~
Unexpected token ')' in expression or statement.
At C:\Users\domin\AppData\Local\Yarn\bin\vuepress.ps1:8 char:3
+ if [ -x "$basedir/pwsh" ]; then
+   ~
Missing '(' after 'if' in if statement.
At C:\Users\domin\AppData\Local\Yarn\bin\vuepress.ps1:8 char:5
+ if [ -x "$basedir/pwsh" ]; then
+     ~
Missing type name after '['.
At C:\Users\domin\AppData\Local\Yarn\bin\vuepress.ps1:9 char:20
+ ... edir/pwsh"  "$basedir/../Data/global/node_modules/.bin/vuepress.ps1"  ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token '"$basedir/../Data/global/node_modules/.bin/vuepress.ps1"' in expression or statement.
At C:\Users\domin\AppData\Local\Yarn\bin\vuepress.ps1:9 char:77
+ ... /pwsh"  "$basedir/../Data/global/node_modules/.bin/vuepress.ps1" "$@"
+                                                                      ~~~~
Unexpected token '"$@"' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : UnexpectedToken

Can anyone help me out with troubleshooting this?

Cheers!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.