├── .gitignore ├── README.md ├── index.js ├── package.json ├── reader.ejs └── screenshot ├── hexo-googledrive-pdf.png ├── hexo-pdf-preview.png └── hexo-slideshare-pdf.png /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | tmp/ 4 | *.log 5 | .idea/ 6 | coverage/ 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | hexo-pdf 2 | ==== 3 | ![MIT](https://img.shields.io/npm/l/express.svg) 4 | ![VERSION](https://img.shields.io/badge/version-1.1.0-green.svg) 5 | 6 | Hexo tag for embeded pdf 7 | 8 | ## Install 9 | 10 | ``` 11 | $ npm install --save hexo-pdf 12 | ``` 13 | 14 | 15 | ## Usage 16 | 17 | ### Normal PDF 18 | 19 | ``` 20 | {% pdf http://7xov2f.com1.z0.glb.clouddn.com/bash_freshman.pdf %} 21 | ``` 22 | 23 | or 24 | ``` 25 | {% pdf ./bash_freshman.pdf %} 26 | ``` 27 | 28 | ### Google drive 29 | ``` 30 | {% pdf https://drive.google.com/file/d/0B6qSwdwPxPRdTEliX0dhQ2JfUEU/preview %} 31 | ``` 32 | 33 | ### Slideshare 34 | ``` 35 | {% pdf http://www.slideshare.net/slideshow/embed_code/key/8Jl0hUt2OKUOOE %} 36 | ``` 37 | ## Preview 38 | 39 | ### Normal PDF 40 | ![](screenshot/hexo-pdf-preview.png) 41 | 42 | ### Google drive 43 | ![](screenshot/hexo-googledrive-pdf.png) 44 | 45 | ### Slideshare 46 | ![](screenshot/hexo-slideshare-pdf.png) 47 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * hexo-pdf 3 | * https://github.com/superalsrk/hexo-pdf.git 4 | * Copyright (c) 2015, superalsrk 5 | * Licensed under the MIT license. 6 | * Syntax: 7 | * {% pdf http://yourdoman.com/x.pdf %} %} 8 | **/ 9 | 10 | var ejs = require('ejs'), 11 | path = require('path'), 12 | fs = require('fs') 13 | 14 | hexo.extend.tag.register('pdf', function(args){ 15 | 16 | var htmlTmlSrc = path.join(__dirname, 'reader.ejs'); 17 | var htmlTml = ejs.compile(fs.readFileSync(htmlTmlSrc, 'utf-8')) 18 | 19 | var type = 'normal'; 20 | var pdfLink = args[0]; 21 | 22 | if (pdfLink.indexOf('.pdf') > 0) { 23 | type = 'normal' 24 | } 25 | else if(pdfLink.indexOf('drive.google.com') > 0) { 26 | type = 'googledoc' 27 | } 28 | else if(pdfLink.indexOf('www.slideshare.net') > 0) { 29 | type = 'slideshare' 30 | } 31 | 32 | return htmlTml({"src": args[0], "type" : type}); 33 | }); 34 | 35 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hexo-pdf", 3 | "version": "1.1.1", 4 | "description": "A Hexo tag extension which allows you to embed pdf on your posts", 5 | "main": "index", 6 | "engines": { 7 | "node": ">= 0.10.0" 8 | }, 9 | "repository": "http://github.com/superalsrk/hexo-pdf", 10 | "keywords": [ 11 | "hexo", 12 | "pdf", 13 | "tag" 14 | ], 15 | "author": "SRK.Lyu (http://stackbox.org)", 16 | "license": "MIT", 17 | "dependencies": { 18 | "ejs": "^1.0.0" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /reader.ejs: -------------------------------------------------------------------------------- 1 | <% if(type == 'normal') { %> 2 | 3 |
4 | 5 |
6 | 7 | <% } else if (type == 'googledoc'){ %> 8 | 9 |
10 | 11 |
12 | 13 | <% } else if(type == 'slideshare') { %> 14 |
15 | <% } %> 16 | -------------------------------------------------------------------------------- /screenshot/hexo-googledrive-pdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superalsrk/hexo-pdf/845fd60270f3b55ba24d5767978fc2e43edbc8cb/screenshot/hexo-googledrive-pdf.png -------------------------------------------------------------------------------- /screenshot/hexo-pdf-preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superalsrk/hexo-pdf/845fd60270f3b55ba24d5767978fc2e43edbc8cb/screenshot/hexo-pdf-preview.png -------------------------------------------------------------------------------- /screenshot/hexo-slideshare-pdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superalsrk/hexo-pdf/845fd60270f3b55ba24d5767978fc2e43edbc8cb/screenshot/hexo-slideshare-pdf.png --------------------------------------------------------------------------------