summary refs log tree commit diff
diff options
context:
space:
mode:
authorPatryk Niedźwiedziński <pniedzwiedzinski19@gmail.com>2020-01-28 18:08:07 +0100
committerPatryk Niedźwiedziński <pniedzwiedzinski19@gmail.com>2020-01-28 18:08:07 +0100
commit4b758eb6dd702c42c192322da87301bbef454838 (patch)
treedd2f2993b4ca365720c6254435189343015c18e9
parent1a5e99c7972968cc384c8dd94bbb92f9c9beac3b (diff)
downloadkronikarz-4b758eb6dd702c42c192322da87301bbef454838.tar.gz
kronikarz-4b758eb6dd702c42c192322da87301bbef454838.zip
Update docs
-rw-r--r--docs/README.md34
-rw-r--r--lib/getPost.ts2
2 files changed, 33 insertions, 3 deletions
diff --git a/docs/README.md b/docs/README.md
index ebfdaa0..4c356bd 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -28,9 +28,39 @@ import Kronikarz from "kronikarz";
 const k = new Kronikarz("path/to/posts");
 ```
 
-At this point only two methods are available.
+### Generating the api
+
+For generating the json api run:
+
+```js
+k.generateApi(`./path`)
+```
+
+This will create all posts list in `./path/api/posts.json` and create json file
+with content for every markdown file in
+`./path/api/posts/{year}/{month}/{day}/{title}.json`.
+
+Also you can specify categories (tags) like this in your post:
+
+```md
+---
+title: Test
+author: Tester
+category:
+    - testing
+---
+```
+
+And it will generate list of all posts in this category in
+`./path/api/category/testing.json`
+
+### Old functions
+
+Now these function will return wrapper of `Post` object. If you want to get a
+simple object like from json api run `post.toApi()`
 
 ```js
 k.getPosts(); // returns array of all posts
-k.getPost("2019", "11", "20", "title"); // returns post from path `2019/11/20/title.md`
+let post = k.getPost("2019", "11", "20", "title"); // returns post from path `2019/11/20/title.md`
+post.toApi();
 ```
diff --git a/lib/getPost.ts b/lib/getPost.ts
index 6e90b1f..4860ff9 100644
--- a/lib/getPost.ts
+++ b/lib/getPost.ts
@@ -14,5 +14,5 @@ export function getPost(
   const filePath = `${path}/${year}/${month}/${day}/${title}.md`;
 
   const post = new Post(filePath);
-    return post;
+  return post;
 }