summary refs log tree commit diff
path: root/src/parsePost.ts
diff options
context:
space:
mode:
authorPatryk Niedźwiedziński <pniedzwiedzinski19@gmail.com>2019-10-13 23:48:12 +0200
committerPatryk Niedźwiedziński <pniedzwiedzinski19@gmail.com>2019-10-13 23:48:12 +0200
commit4274595b251632ef004d5f1429d7fbdde1cd4a5a (patch)
treec8a5ac120ddd03e161ecac522b1180f3a815cf70 /src/parsePost.ts
parent0ccea881106946b66d167eee0ec8116ae4e3019e (diff)
downloadkronikarz-4274595b251632ef004d5f1429d7fbdde1cd4a5a.tar.gz
kronikarz-4274595b251632ef004d5f1429d7fbdde1cd4a5a.zip
Add publish options
Diffstat (limited to 'src/parsePost.ts')
-rw-r--r--src/parsePost.ts45
1 files changed, 0 insertions, 45 deletions
diff --git a/src/parsePost.ts b/src/parsePost.ts
deleted file mode 100644
index 01e8d1c..0000000
--- a/src/parsePost.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-import * as fs from "fs";
-import { JSDOM } from "jsdom";
-import { Post, PostContent } from "./interfaces";
-
-const frontmatter = require("front-matter");
-const md = require("markdown-it")();
-
-function getDescription(html: string): string {
-  const { document } = new JSDOM(`<div>${html}</div>`).window;
-  const elements = document.getElementsByTagName("p");
-
-  const description = elements[1].textContent;
-
-  return description || "";
-}
-
-function getPostContent(fileContent: string): PostContent {
-  const post = frontmatter(fileContent);
-
-  const markdown = post.body;
-  const html = `<div>${md.render(markdown)}</div>`;
-  const description = getDescription(html);
-
-  return {
-    html,
-    markdown,
-    description,
-    meta: post.attributes
-  };
-}
-
-export default function parsePost(filePath: string): Post {
-  const [year, month, day, title] = filePath.split("/").splice(-4, 4);
-  const date = { year, month, day };
-  const fileContent = fs.readFileSync(filePath, "utf-8");
-  const content = getPostContent(fileContent);
-
-  return {
-    date,
-    title: title.substr(0, title.lastIndexOf(".")),
-    content,
-    filePath,
-    route: `/kronika/${year}/${month}/${day}/${title}`
-  };
-}