The Details Usage of the Hexo Next-Theme Plugin `next-pdf`
This post will introce the usage of the plugin which allows to preview PDF files in the blog pages.
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
See Github.
Usage
In order to embed PDF files in the article(.md
) , you just need to create an pdf
tag with the URL of your local PDF file, e.g.
1 | {% pdf https://domin.com/files/file.pdf %} |
or
1 | {% pdf /path/to/your/file.pdf %} |
obviously, it’s very easy to actualize by url
, but it will need some configure for yourself to use it when you have to use by local file path
.
Step 1
Change dir to Hexo directory. There must be source, themes and other directories.
1 | cd source |
files
folder will be used to store files (e.g. *.pdf
).
Obviously, you can set anyname for folder, but the posterior config will need to modify.
Modify _config.yml
:
1 | skip_render: |
In this way, you can deploy the files
folder in the public
folder when executed $ hexo generate
about include
you can see hexo-configuration.
Step 2
Change dir to Next Theme directory.
Modify _config.yml
:
1 | # Dependencies: https://github.com/next-theme/theme-next-pdf |
Step 3
For example: the pdf files path: Hexo directory/source/files/filename.pdf
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 ../../files/filename.pdf %} |
Enjoy it!