-
Notifications
You must be signed in to change notification settings - Fork 1
/
html.js
64 lines (45 loc) · 2.07 KB
/
html.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
var fs=require('fs') ;
var ejs=require('ejs') ;
var blog = require('./lib/nedb/blog');
var config = require('./lib/config').config;
//function html(mpath,file,baoqian,shuju) {
fs.readFile('./views/blogindex.html', function (e, v) {
console.log(e,v) ;
var mb= v.toString() ;
var classname='' ;
classname = classname + '<ul class="nav pull-right navbar-nav">';
classname = classname + '<li><a href="/">首页</a></li>';
var xuanzhong = config.menu;
for (var i = 0; i < xuanzhong.length; i++) {
if ( v[i].column&&xuanzhong[i].m == v.column) {
classname = classname + '<li class="active"><a href="' + xuanzhong[i].url + '">' + xuanzhong[i].name + '</a></li>';
}
else {
classname = classname + '<li><a href="' + xuanzhong[i].url + '">' + xuanzhong[i].name + '</a></li>';
}
}
classname = classname + '</ul>';
blog.list().then(function(v)
{
for (var i = 0; i < v.length; i++) {
var options =v[i] ;
// options.title='聂峰军个人网站';
options.classname=classname ;
var template = ejs.render(mb, options);
fs.writeFile('./public/blog/'+ v[i]._id +'.html', template, function (err) {
if (err) throw err;
//console.log("Export Account Success!");
});
//list = list + '<item>';
//list = list + '<author>' + v[i].title + '</author>';
//list = list + '<title><![CDATA[' + (v[i].title) + ']]></title>';
//list = list + '<link>http://niefengjun.cn/blog/' + v[i]._id + '.html</link>';
//list = list + '<description><![CDATA[' + delHtmlTag(v[i].content) + ']]></description>';
//list = list + '<pubDate>' + v[i].created + '</pubDate>';
//list = list + '</item>';
}
}
);
}
)
//}