diff options
author | Patryk Niedźwiedziński <pniedzwiedzinski19@gmail.com> | 2020-01-28 18:16:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-28 18:16:03 +0100 |
commit | 42c089293fed2db9c8a09d8e55f046169b5f0844 (patch) | |
tree | 18a053fe7f1e03fc5419a8c3d2a8bc8193cb27f0 /docs/README.md | |
parent | 7b8d75cd87e392d9ffb3defa538a041c4f7e0f0c (diff) | |
parent | acfd4d0c722ceeca6aad51be64baf117e73f286c (diff) | |
download | kronikarz-42c089293fed2db9c8a09d8e55f046169b5f0844.tar.gz kronikarz-42c089293fed2db9c8a09d8e55f046169b5f0844.zip |
Merge pull request #8 from pniedzwiedzinski/feature/generateApi v2.0
Feature/generate api
Diffstat (limited to 'docs/README.md')
-rw-r--r-- | docs/README.md | 34 |
1 files changed, 32 insertions, 2 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(); ``` |