about summary refs log tree commit diff
path: root/api/api.js
diff options
context:
space:
mode:
Diffstat (limited to 'api/api.js')
-rw-r--r--api/api.js21
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
+}