This is THE data library of the ecosystem. It serialises and deserialises the post JSON and is being relied upon by the rest of the ecosystem: namely by the blog.engine and the blog.generator.
Given that the blog.engine is written in Elm, using anything but Elm is difficult. In theory we could possibly use ports, but sending messages back and forth just to decode JSON doesn’t make sense, especially for something that needs to happen really fast.
Since Elm doesn’t support private packages, the best way to go about this is to add the library as a git submodule and extend the compile function to tangle blocks from src/Post.org into src/Post.elm
of the host repository.
Elm itself doesn’t allow exporting JavaScript functions. The closest we get is a headless program (based on messaging, just like Browser.application
), which is an overkill for a few functions.
Fortunatelly there is elm2node. It is a fork of Elm 0.19.1 compiler, but generates normal JS code as the output. It has limitations however, for instance the exported functions has to have arity 1.
This repository is only one of many packages that I wrote for my blog. For the overall architecture and documentation please see the blog meta repo. That’s also the place to raise any issues if you encounter any and to discuss the project and ask questions.
Where’s all the source code?
In case you’re wondering where are all the Elm files, you have to tangle code blocks from Org mode files in src
into actual Elm files using Org mode in Emacs.
Don’t worry about it though – unless you want to set up the code locally, there is no need. Just read the Org mode files in the src
directory, it contains well-documented code.
If you’re curious why am I doing this, you can check my post on literate programming.
If you want to contribute or just play around with it, check out how to set up the repository.