aboutsummaryrefslogtreecommitdiff
path: root/index.js
blob: 1265c75317adeaf7a8527e37c2c1951cb6a6594c (plain) (blame)
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
const glob = require("glob");
const generateTags = require("./generate-tags.js");
const loadArticle = require("./load-article.js");
const saveArticle = require("./save-article.js");
const saveIndex = require("./save-index.js");
const saveStaticFile = require("./save-static-file.js");
const save32x32 = require("./save-32x32.js");

glob("articles/*.md", (err, articles) => {
  if (err) { throw err; }

  Promise.all(articles.map(loadArticle))
    .then(articles => {
      const promises = articles.map(saveArticle);

      promises.push(saveIndex(articles, "output/index.html"));
      promises.push(generateTags(articles));

      return Promise.all(promises);
    })
    .then(
      () => console.log("Articles built."),
      err => {
        console.log("Error building articles.");
        console.log(err);
      }
    );
});

glob("public/**/*.*", (err, staticFiles) => {
  if (err) { throw err; }

  Promise.all(staticFiles.map(saveStaticFile))
    //.then(save32x32)
    .then(
      () => console.log("Static files built."),
      err => {
        console.log("Error saving static files.");
        console.log(err);
      }
    );
});