PDF.js for NexT
Introduce
This is a plugin that allows to preview PDF files in the blog pages.
If the browser supports embedded PDFs natively, NexT will create a <embed>
tag and include the PDF file on your website. Otherwise it will create a <iframe>
tag and uses PDF.js by @mozilla to render the pdf file.
Follow the guide below to install dependencies.
Installation
Step 1 → Go to NexT dir
Change dir to NexT directory. There must be layout
, source
, languages
and other directories:
1 | $ cd themes/next |
Step 2 → Get module
Install module to source/lib
directory:
1 | $ git clone https://github.com/theme-next/theme-next-pdf source/lib/pdf |
Step 3 → Set it up
Enable module in NexT _config.yml
file:
1 | # PDF tag |
Usage
In order to embed PDF files in the article, you just need to create an
pdf
tag with the URL of your local PDF file, e.g.1 | {% pdf /path/to/your/file.pdf %} |
Notice: Do not use cross-origin PDF files, it might be blocked by the CORS policy.
Enjoy it!
Update
1 | $ cd themes/next/source/lib/pdf |