diff options
author | Patryk Niedźwiedziński <pniedzwiedzinski19@gmail.com> | 2019-10-12 15:40:51 +0200 |
---|---|---|
committer | Patryk Niedźwiedziński <pniedzwiedzinski19@gmail.com> | 2019-10-12 15:40:51 +0200 |
commit | d92f1a2a1bac3039434a16c504cc1d54c6d0409a (patch) | |
tree | c0c5b9d4539512b44a4c99a114d3ef523cc92e73 /api | |
parent | 7a17a28220a84c294728f572932b1619d92c1d95 (diff) | |
download | puszcza-d92f1a2a1bac3039434a16c504cc1d54c6d0409a.tar.gz puszcza-d92f1a2a1bac3039434a16c504cc1d54c6d0409a.zip |
Change posts location
Diffstat (limited to 'api')
-rw-r--r-- | api/api.js | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/api/api.js b/api/api.js index a704912..1675d7e 100644 --- a/api/api.js +++ b/api/api.js @@ -1,12 +1,12 @@ const fs = require('fs') const frontmatter = require('front-matter') -const POSTS_PATH = './kronika/wpisy' +const POSTS_PATH = './content/wpisy' function getPostAttributes(filePath) { - const fileContent = fs.readFileSync(filePath, "utf-8") + const fileContent = fs.readFileSync(filePath, 'utf-8') - const post = frontmatter(fileContent); + const post = frontmatter(fileContent) return post.attributes } @@ -14,15 +14,15 @@ function getPosts() { const routesArray = [] try { const years = fs.readdirSync(`${POSTS_PATH}`) - years.forEach((year) => { + years.forEach(year => { const months = fs.readdirSync(`${POSTS_PATH}/${year}`) - months.forEach((month) => { + months.forEach(month => { const days = fs.readdirSync(`${POSTS_PATH}/${year}/${month}`) - days.forEach((day) => { + days.forEach(day => { const files = fs.readdirSync(`${POSTS_PATH}/${year}/${month}/${day}`) - files.forEach((file) => { + files.forEach(file => { const title = file.substr(0, file.lastIndexOf('.')) - const route = `/kronika/${year}/${month}/${day}/${title}` + const route = `/kronika/${year}/${month}/${day}/${title}/` const fsRoute = `${POSTS_PATH}/${year}/${month}/${day}/${file}` const attributes = getPostAttributes(fsRoute) @@ -41,8 +41,7 @@ function getPosts() { }) }) }) - } - finally { + } finally { return routesArray } } @@ -55,4 +54,4 @@ function createRoutesArray() { module.exports = { getPosts, createRoutesArray -} \ No newline at end of file +} |