-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
38 lines (33 loc) · 857 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
34
35
36
37
38
'use strict'
const fs = require('fs-extra-promise')
const path = require('path')
const beautify_html = require('js-beautify').html
require('./lib')
hane.readConfig()
require('../hane-render-markdown')
require('../hane-theme-simple')
const distPath = path.join(__dirname, '../dist')
async function main() {
const { render, theme } = hane.runtime
const result = await render.feed('# Render test')
let html = await theme.render({
categories: [],
items: [
{
title: 'Hello World',
content: result,
pubDate: new Date().toString(),
},
],
tags: [],
})
if (hane.config.theme.beautify) {
html = beautify_html(html, { indent_size: 2 })
}
try {
await fs.mkdirAsync(distPath)
} catch (e) {}
await fs.writeFileAsync(path.join(distPath, 'index.html'), html)
console.log('done')
}
main()