diff --git a/src/about.js b/src/about.js index 32e31854..383b0dee 100644 --- a/src/about.js +++ b/src/about.js @@ -18,11 +18,12 @@ const posthtml = data => `
- F/OSS Comics + F/OSS Comics
diff --git a/src/homepage.js b/src/homepage.js index 33c114bd..7e244d16 100644 --- a/src/homepage.js +++ b/src/homepage.js @@ -17,7 +17,8 @@ const homepage = posts => `
${config.blogName}
diff --git a/src/index.js b/src/index.js index 0799e20a..7de48791 100644 --- a/src/index.js +++ b/src/index.js @@ -4,6 +4,7 @@ const postMethods = require("./posts"); const aboutMethod = require("./about"); const config = require("./config"); const addHomePage = require("./homepage"); +const addListPage = require("./list"); const posts = fs .readdirSync(config.dev.postsdir) @@ -17,6 +18,7 @@ if (!fs.existsSync(config.dev.outdir)) fs.mkdirSync(config.dev.outdir); postMethods.createPosts(posts); addHomePage(posts); +addListPage(posts); // Create about page const about = aboutMethod.readAbout(config.dev.about); diff --git a/src/list.js b/src/list.js new file mode 100644 index 00000000..00728552 --- /dev/null +++ b/src/list.js @@ -0,0 +1,65 @@ +const config = require("./config"); +const fs = require("fs"); + +const listpage = posts => ` + + + + + + + + + ${config.blogName} + + +
+
+
${config.blogName}
+ +
+

All articles

+
    + + ${posts + .map( + post => `
  • + ${ + post.attributes.title + } + ${new Date( + post.attributes.date + ).toDateString()} +
  • ` + ) + .join("")} + +

+ + +`; + +const addListPage = posts => { + fs.writeFile(`${config.dev.outdir}/posts.html`, listpage(posts), e => { + if (e) throw e; + console.log(`index.html was created successfully`); + }); +}; + +module.exports = addListPage; diff --git a/src/posts.js b/src/posts.js index 6289c08e..8c419da7 100644 --- a/src/posts.js +++ b/src/posts.js @@ -22,7 +22,7 @@ const posthtml = data => `