From 9165c00fef52dee1ba6b745cae84e9d734abe306 Mon Sep 17 00:00:00 2001 From: Patryk Niedźwiedziński Date: Mon, 14 Oct 2019 09:58:58 +0200 Subject: Fix route generation --- lib/parsePost.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib') 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}` -- cgit 1.4.1