https://github.com/next-theme/theme-next-pdf
:bookmark_tabs: PDF.js for NexT.
https://github.com/next-theme/theme-next-pdf
Last synced: 22 days ago
JSON representation
:bookmark_tabs: PDF.js for NexT.
- Host: GitHub
- URL: https://github.com/next-theme/theme-next-pdf
- Owner: next-theme
- License: apache-2.0
- Created: 2020-05-09T04:35:05.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-04-06T00:42:31.000Z (29 days ago)
- Last Synced: 2025-04-06T01:24:12.095Z (29 days ago)
- Language: JavaScript
- Homepage: http://github.com/mozilla/pdf.js
- Size: 112 MB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [PDF.js](https://github.com/mozilla/pdf.js) for [NexT](https://github.com/next-theme/hexo-theme-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 `` tag and include the PDF file on your website. Otherwise, it will create a `` tag and uses PDF.js by @mozilla to render the pdf file.
Follow the guide below to install the plugin.
## Installation
### Step 1 → Go to Hexo dir
Change dir to **Hexo** directory. There must be `source`, `themes` and other directories:
```sh
$ cd hexo-site
$ ls
_config.next.yml db.json package-lock.json scaffolds themes
_config.yml node_modules package.json source
```### Step 2 → Install plugin
If you have already added the **Hexo** directory to a git repository, then install this plugin as a git submodule:
```sh
$ git submodule add https://github.com/next-theme/theme-next-pdf source/lib/pdf
```Otherwise, install the plugin to `source/lib` directory via `git clone`:
```sh
$ git clone https://github.com/next-theme/theme-next-pdf source/lib/pdf
```### Step 3 → Set it up
Enable the plugin in **NexT** `_config.next.yml` file:
```yml
# PDF tag
# NexT will try to load pdf files natively, if failed, pdf.js will be used.
# So, you have to install the dependency of pdf.js if you want to use pdf tag and make it available to all browsers.
# See: https://github.com/next-theme/theme-next-pdf
pdf:
enable: true
# Default height
height: 500px
```Find and edit `skip_render` settings in **Hexo** `_config.yml` file:
```yml
skip_render:
- lib/**/*
```## Usage
In order to embed PDF files in the article, you just need to create `pdf` tags with the URL of your local PDF file, e.g.
```
{% 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
```sh
$ cd hexo-site/source/lib/pdf
$ git pull
```