diff options
author | Patryk Niedźwiedziński <pniedzwiedzinski19@gmail.com> | 2019-10-14 09:58:58 +0200 |
---|---|---|
committer | Patryk Niedźwiedziński <pniedzwiedzinski19@gmail.com> | 2019-10-14 09:58:58 +0200 |
commit | 9165c00fef52dee1ba6b745cae84e9d734abe306 (patch) | |
tree | baef09363d9f2f0ce3ea0bd19e7048917b4451ae | |
parent | 49e82e812812ba75175d98173379d2e416e17b8f (diff) | |
download | kronikarz-9165c00fef52dee1ba6b745cae84e9d734abe306.tar.gz kronikarz-9165c00fef52dee1ba6b745cae84e9d734abe306.zip |
Fix route generation
-rw-r--r-- | lib/parsePost.ts | 5 | ||||
-rw-r--r-- | package.json | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/lib/parsePost.ts b/lib/parsePost.ts index 416dd16..2f5f2b9 100644 --- a/lib/parsePost.ts +++ b/lib/parsePost.ts @@ -30,14 +30,15 @@ function getPostContent(fileContent: string): PostContent { } export function parsePost(filePath: string): Post { - const [year, month, day, title] = filePath.split("/").splice(-4, 4); + let [year, month, day, title] = filePath.split("/").splice(-4, 4); + title = title.substr(0, title.lastIndexOf(".")); const date = { year, month, day }; const fileContent = fs.readFileSync(filePath, "utf-8"); const content = getPostContent(fileContent); return { date, - title: title.substr(0, title.lastIndexOf(".")), + title, content, filePath, route: `/kronika/${year}/${month}/${day}/${title}` diff --git a/package.json b/package.json index 7a67237..3929deb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kronikarz", - "version": "0.1.2", + "version": "0.1.3", "description": "System elektronicznej kroniki", "main": "dist/index.js", "types": "dist/index.d.ts", |