IHP 1.3 is out now!

Creating blog posts using markdown files

harris-chris

Hi - I've recently started using IHP for a personal blog and am finding it a real pleasure so far. One thing that slightly surprises me is that it seems storing the blog posts in the database seems to be the only way to go. This feels a little cumbersome, because I then have to write them via the front-end, and maintain a Controller for doing so (I haven't yet figured out how to hide this from the users). Ideally I would like to just write markdown files using vim and then somehow put them up as blog posts. I realize that at the moment the database is the only storage mechanism, but is there an idiomatic approach you'd take to facilitate a workflow like that? Obviously I can write them as markdown files and then copy/paste them into newly created posts on the front-end, so it's not exactly a huge deal, but if there's an obvious work-around I'd like to know.

Thanks for a great piece of software!

Chris

marc PRO

hey, you could manually write some haskell code that finds all .md files in e.g. static/posts and then try to serve it from there.

The more-IHP way is to use the controller setup as you mentioned already. You have multiple options to hide the backend part from the user:

  • generate a admin application using the code gen and then use that for admin stuff. We use this strategy on the IHP website as well. Check the code here: https://github.com/digitallyinduced/ihp-website
  • put a basic auth in front of the action (we also used that a while ago for the IHP website backend before making a Admin app). Check an example in the docu here: https://ihp.digitallyinduced.com/Guide/authentication.html
harris-chris

Hi Marc - thanks - that's helpful. Scanning and reading file would involve the IO monad so I'm a bit wary about that route, but I might check it out and see if it's viable. Either way appreciate the response.

HugoPeters1024

Do not fear the monads Chris! I would say that it is a perfectly suitable reason to use the IO monad in this case. Come and join the IHP slack if you need some help with that :)