forked from davidjgoss/slack-export-viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
47 lines (44 loc) · 1.29 KB
/
build.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
const WORKSPACE_NAME = "example-workspace";
const fs = require("fs"),
rimraf = require("rimraf"),
Handlebars = require("handlebars"),
Metalsmith = require('metalsmith'),
collections = require('metalsmith-collections'),
discoverPartials = require("metalsmith-discover-partials"),
layouts = require('metalsmith-layouts'),
render = require("./lib/render");
console.log("Processing exported Slack data...");
const slackData = require("./lib/data")();
rimraf.sync("./src/channels/*.html");
Object.keys(slackData.channels).forEach(channelName => {
fs.writeFileSync(`./src/channels/${channelName}.html`, `---
layout: channel.hbs
name: ${channelName}
---`);
});
console.log("Generating site...");
Handlebars.registerHelper("view_channel", render);
Metalsmith(__dirname)
.metadata({
workspaceName: WORKSPACE_NAME,
slack: slackData
})
.source('./src')
.destination('./build')
.clean(true)
.use(collections({
channels: {
pattern: 'channels/*.html'
}
}))
.use(discoverPartials())
.use(layouts({
engine: 'handlebars'
}))
.build(err => {
if (err) {
throw err;
} else {
console.log("Successfully generated to build/ - test with `npm start`");
}
});