-
Notifications
You must be signed in to change notification settings - Fork 15
/
index.js
34 lines (27 loc) · 760 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* hexo-pdf
* https://github.com/superalsrk/hexo-pdf.git
* Copyright (c) 2015, superalsrk
* Licensed under the MIT license.
* Syntax:
* {% pdf http://yourdoman.com/x.pdf %} %}
**/
var ejs = require('ejs'),
path = require('path'),
fs = require('fs')
hexo.extend.tag.register('pdf', function(args){
var htmlTmlSrc = path.join(__dirname, 'reader.ejs');
var htmlTml = ejs.compile(fs.readFileSync(htmlTmlSrc, 'utf-8'))
var type = 'normal';
var pdfLink = args[0];
if (pdfLink.indexOf('.pdf') > 0) {
type = 'normal'
}
else if(pdfLink.indexOf('drive.google.com') > 0) {
type = 'googledoc'
}
else if(pdfLink.indexOf('www.slideshare.net') > 0) {
type = 'slideshare'
}
return htmlTml({"src": args[0], "type" : type});
});