使用 Github 空间搭建 Hexo 技术博客——Hexo NexT主题内添加pdf 插件(十一)

需求:

希望能在GitHub搭建的博客中上传本地PDF文件,同时提供下载功能。

一、安装插件

npm install --save hexo-pdf

next/_config.yml中修改此处:打开pdf

pdf:
  enable: true
  # Default height
  height: 500px
  pdfobject:
    # Use 2.1.1 as default, jsdelivr as default CDN, works everywhere even in China
    cdn: //cdn.jsdelivr.net/npm/[email protected]/pdfobject.min.js
    # CDNJS, provided by cloudflare, maybe the best CDN, but not works in China
    #cdn: //cdnjs.cloudflare.com/ajax/libs/pdfobject/2.1.1/pdfobject.min.js

若建立页面如下图,则看二和三,如建立文章形式,直接看四

二、若建立页面

创建 book 页面

hexo new page book 

三、编写

在生成的md文件中添加pdf

外部链接:
{% pdf http://7xov2f.com1.z0.glb.clouddn.com/bash_freshman.pdf %}
本地连接:
{% pdf ./pdf名字.pdf %}

还要如图设置:

四、若建立文章形式

使用

外部文章网页链接

{% pdf http://7xov2f.com1.z0.glb.clouddn.com/bash_freshman.pdf %}

本地,即我们需要上传的【需求】

在博客source\_posts\,文件夹下创建一个文章如test.md,同时需要再创建一个同名的test文件夹,放我们要上传的PDF文章

---
title: 测试使用
date: 2019-03-10 20:07:12
tags: 测试
categories: 测试
---
 
 
<center>**测试**</center>
 
 
<br>
 
 
{% pdf 路径.pdf %} 
 
 
</br>

最后使用命令:hexo g 生成; hexo d 发布后,即可实现需求

发布了120 篇原创文章 · 获赞 201 · 访问量 23万+

猜你喜欢

转载自blog.csdn.net/wugenqiang/article/details/88377669