diff options
author | Alan Pearce | 2017-06-18 13:36:29 +0200 |
---|---|---|
committer | Alan Pearce | 2017-06-18 13:36:29 +0200 |
commit | 69af7f12ec17f0aba65b0e23ef4045ee28f2dac8 (patch) | |
tree | 281781690d7bfe4952205e33ec26dff2f442aa57 /src/modules | |
parent | 370e7add837f194bebc710c10ccd11bacfc74990 (diff) | |
download | homestead-69af7f12ec17f0aba65b0e23ef4045ee28f2dac8.tar.lz homestead-69af7f12ec17f0aba65b0e23ef4045ee28f2dac8.tar.zst homestead-69af7f12ec17f0aba65b0e23ef4045ee28f2dac8.zip |
feat: add single post endpoint
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/posts.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/modules/posts.js b/src/modules/posts.js index 26db63d..2d831af 100644 --- a/src/modules/posts.js +++ b/src/modules/posts.js @@ -28,8 +28,18 @@ function get (filename) { return canonicaliseMetadata(matter.read(filename, grayMatterOptions)) } +function getTitle (file) { + return path.basename(file.path, path.extname(file.path)) +} + function getFolder (folder) { - return fs.readdirSync(folder).map(f => path.resolve(folder, f)).map(get) + return new Map( + fs + .readdirSync(folder) + .map(f => path.resolve(folder, f)) + .map(get) + .map(f => [getTitle(f), f]) + ) } module.exports = { |