about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorAlan Pearce2017-06-18 12:35:49 +0200
committerAlan Pearce2017-06-18 12:35:49 +0200
commitbf20f4f6d97b8d2643f19ed7ac617c33a7f2ea6b (patch)
treef93779b36b3e2bc31126b467f0a16ababa79cd78 /src
parent75ef26ea24032c7e8a6a5d63e65c70d43c88a938 (diff)
downloadhomestead-bf20f4f6d97b8d2643f19ed7ac617c33a7f2ea6b.tar.lz
homestead-bf20f4f6d97b8d2643f19ed7ac617c33a7f2ea6b.tar.zst
homestead-bf20f4f6d97b8d2643f19ed7ac617c33a7f2ea6b.zip
refactor: metadata -> posts
Diffstat (limited to 'src')
-rw-r--r--src/index.js6
-rw-r--r--src/modules/posts.js (renamed from src/modules/metadata.js)13
2 files changed, 8 insertions, 11 deletions
diff --git a/src/index.js b/src/index.js
index c16d952..3d25faa 100644
--- a/src/index.js
+++ b/src/index.js
@@ -10,14 +10,14 @@ const router = new Router()
 
 const view = require('koa-nunjucks-next')
 
-const metadata = require('./modules/metadata.js')
-const postMetadata = metadata.getFolderMetadata(process.env.POST_DIR)
+const Posts = require('./modules/posts.js')
+const posts = Posts.getFolder(process.env.POST_DIR)
 
 app.use(view(`${__dirname}/views`))
 
 router.get('/', async function (ctx, next) {
   await ctx.render('index', {
-    posts: postMetadata
+    posts
   })
 })
 
diff --git a/src/modules/metadata.js b/src/modules/posts.js
index f35031d..e005103 100644
--- a/src/modules/metadata.js
+++ b/src/modules/posts.js
@@ -24,18 +24,15 @@ function canonicaliseMetadata (meta) {
   return meta
 }
 
-function getFileMetadata (filename) {
+function get (filename) {
   return canonicaliseMetadata(matter.read(filename, options))
 }
 
-function getFolderMetadata (folder) {
-  return fs
-    .readdirSync(folder)
-    .map(f => path.resolve(folder, f))
-    .map(getFileMetadata)
+function getFolder (folder) {
+  return fs.readdirSync(folder).map(f => path.resolve(folder, f)).map(get)
 }
 
 module.exports = {
-  getFileMetadata,
-  getFolderMetadata
+  get,
+  getFolder
 }