Sign in

output every blog post as json

  • This topic has 2 replies, 2 voices, and was last updated 1 week, 4 days ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #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!

    #4180
    Tomasz Dziuda
    Moderator

    Hi,

    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 template

    3) 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!

    #4193
    deimos

    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.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.