Using nushell as a blogging engine


While perusing the speed and efficiency of a php server here on envs.net, I've decided that JetBrainsMono default font served on this host is neat and so I'm putting some effort in setting up the roots of this blog. I've made a custom Nushell procedure that indexes all the markdown files and places them in the custom xml tags with the htmz swap attributes. I'm leaning on using the details-summary native html accordion.


This is the script for building the blog index.


# blog index, grabs all of the markdown files and constructs the full link tree in html, requires the html compile
{tag: details attributes: {name: "blog-focus"} content: ({tag: summary content: ["blog"] }
| append (glob *.md | path parse | get stem | each {|| {tag: section attributes: {id: ($in)} content: [ {tag: section attributes: {id: ($in)} content: [{tag: a attributes: {href: /blog/($in).html#($in)} content:[(head -n 1 $"($in).md" | str replace "# " "")]}]} ]}})
)}
| append {tag: details attributes: {name: "blog-focus"} content: [{tag: summary content: ["collapse"] }]}
# | append (glob *.md | path parse | get stem | each {|| {tag: section attributes: {id: ($in)} content: [{tag: a attributes: {href: /blog/($in).html#($in)} content:[(head -n 1 $"($in).md" | str replace "# " "")]}]} })
| {tag: section attributes: {id: panel, role: tabpanel} content: $in }
| to xml | save index.html -f
#| table -e

And here is the very simple markdown to html converter that batch processes everything.


	glob *.md | each {|x| open $x | comrak | to html --raw --partial -d | save $"($x|path parse | get stem).html" -f}

I suppose there is one dependency I have forgotten to mention which is comrak. At the moment, it is very simple and we'll see how maintainable this is going forward with more metadata and tags. I personally find it a bit refreshing to build this with my own hands versus relying on a build process like hugo or jekyll. The latency on this server is astoundingly good for where I am located geographically given the other alternatives, but I haven't tested it extensively.