output every blog post as json
- This topic has 2 replies, 2 voices, and was last updated 4 months, 1 week ago by .
- AuthorPosts
- October 17, 2020 at 4:55 am#4173
deimos
Hi,
I’m trying to build a mongodb search engine of every post in a blog (roughly 800 posts). Is there a relatively easy way to do this? I’ve tried re-using some of the code which generates the feed.json file. I’ve also started down the path to use this templates, https://github.com/GetPublii/Publii/blob/8db728c848a7c2e8c15770d1fd96e7e38304a8dd/app/default-files/theme-files/feed-json.hbs, to pull from the sqlite db to generate the json per post.
Is there some easier way to accomplish the goal?
Thanks!
October 17, 2020 at 1:35 pm#4180Tomasz Dziuda
ModeratorHi,
My idea, but please remember – it is only idea, which wasn’t tested –
1) create a custom post template
2) create a new hidden post and assign this new custom post template3) then render the JSON in the template using @website.contentStructure global variable: https://getpublii.com/dev/website-global-variable/ and use feed-json.hbs as an inspiration
Of course you will get JSON inside HTML file, but as I suppose – you just need raw JSON data.
--
Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!October 19, 2020 at 5:08 am#4193deimos
Thanks!
For now, I just use the JSON extension to sqlite3 and this query gets the core data into a usable format:
SELECT title, authors.name, text, created_at FROM posts JOIN authors;
Not quite as cool as running js templates, but gets the job done.
- AuthorPosts
- You must be logged in to reply to this topic.