logoalt Hacker News

sillysaurusxlast Thursday at 11:29 PM1 replyview on HN

Beautiful. I don't suppose you have public, detailed installation steps for how to go from "nothing exists" to "Pandoc can push posts to https://blog.moertel.com/"? :)

The best I was able to do was http://github.com/shawwn/wiki, which has been broken since 2020. You can't spell Haskell without Hell.

If you wouldn't mind pulling up a `claude` in your repo and running `/init` and showing the result, that'd give me at least a vague idea of what to do.


Replies

tmoertellast Thursday at 11:53 PM

Thanks. I do not have a public, detailed description of how my blog works. But in short, my site build system is powered by a Makefile that invokes Hakyll [1]. My Hakyll configuration has the following rule baked into it for generating HTML docs from Markdown docs in the `posts/` directory:

    match "posts/*" $ do
        route $ setExtension "html"
        let ctx = postCtx tags
        compile $ pandocMathCompiler
            >>= loadAndApplyTemplate "templates/post.html" ctx
            >>= saveSnapshot "content"
            >>= loadAndApplyTemplate "templates/add-comments.html" ctx
            >>= loadAndApplyTemplate "templates/default.html" ctx
            >>= relativizeUrls
The `pandocMathCompiler` bit invokes Hakyll's Pandoc subsystem with support for rendering formulas using MathJax.

The site Makefile also has rules to build PDF versions of the articles that I want to typeset. The rules just invoke Pandoc directly. For example, here's the rule used to generate the PDF file in my prior comment:

    sampling-with-sql.pdf: posts/2024-08-23-sampling-with-sql.md
            ( cd posts && pandoc --metadata-file=../templates/latex-header-includes.yaml -t pdf -o ../[email protected] --pdf-engine=pdflatex ../$< && mv -f ../[email protected] ../$@ )
It's basically a straightforward invocation of Pandoc with a little shell boilerplate to prevent the PDF file from being moved into its final location unless Pandoc exits with success.

The Makefile has a final "push" target that makes sure the site's assets are up to date (invoking Hakyll if needed) and then pushes the static site up to the content distribution network I'm using to publish my website.

[1] https://jaspervdj.be/hakyll/

show 1 reply