riichard/jekyll-rest-api

Could you tell me how to use it?

Closed this issue · 10 comments

Could you tell me how to use it?

Do you mean how to install it or how to execute the queries?

@riichard yes, how to expose the api with json response?

@JimmyLv You can install it via bower, when then compiling it with jekyll it should be available.

Installing via bower
bower install jekyll-rest-api

Then you can access it by

http://myjekyllsite.com/bower_components/jekyll-rest-api/posts.json

@JimmyLv Does this solve your problem?

@riichard Thank thank you very much! I did it!! BTW: how can I generate each json file for each post, so that I can use path like xxxxx/2016/01/22/React.js-Best-Practices-for-2016.html easily change to xxxxx/2016/01/22/React.js-Best-Practices-for-2016.json.

@JimmyLv I'm afraid that's not possible yet. But I'll look into in! 👍

@JimmyLv The best thing you can do is to get all posts, and then filter that specific post you have out of it.
I assume the file isn't that big, and is loaded quickly because the browser doesn't have to render it in the DOM.

If you have a lot of blog posts that this really becomes inefficient, you can make a work-around by creating a fork of your blog, change the layout file in your _layouts folder to generate json, and set up a hook to sync all new posts/updates to your forked _posts folder. It sounds like a lot of work, but if you really need to do it, this is the only way.

@riichard Thanks for your patience~ Let me have a try at first..

Hi @JimmyLv I see you reopened this issue. Can I help you with something?

i'm closing this issue due to long time no response, hope all is well Jimmy ;)