-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
31 lines (27 loc) · 961 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
// hexo-maxcdn-plugin
// Copyright (c) 2013 - MaxCDN, a division of NetDNA, LLC.
//
// MIT Licensed
// * Author: [@mervinej](https://twitter.com/#!/mervinej)
var maxcdn = require('./maxcdn.js');
hexo.extend.helper.register('maxcdn', maxcdn.maxcdnify);
hexo.extend.tag.register('maxcdn', function (args) {
if (!args.length) {
maxcdn.throwError('tag require path');
}
var path = args.shift()
.replace(/^'/,'')
.replace(/^"/,'')
.replace(/'$/,'')
.replace(/"$/,'');
var attrs = {};
args.forEach(function(arg) {
var splitArg = arg.split('=');
attrs[splitArg[0]] = (splitArg[1]||'')
.replace(/^'/,'')
.replace(/^"/,'')
.replace(/'$/,'')
.replace(/"$/,'');
});
return maxcdn.maxcdnify(path, attrs);
});