What
A notebook-inspired shortcode component to help document Hugo projects.
Note that unlike “usual” notebooks, this is not interactive.
Why
I needed one, and I thought it might be useful to others as well.
How to use
Documentation is available at the repos:
Component repo: GitHub - pointyfar/hugo-notebook
Demo repo: GitHub - pointyfar/hugo-notebook-example
Demo site: https://elated-ardinghelli-b1f122.netlify.app/
How it works
Example md:
---
title: "Two"
foo:
- bar
- baz
lorem: ipsum
---
{{< notebook-helper/notebook >}}
{{ range $i, $e := .Params.foo }}
{{ $i }}: {{ $e }}
<br>
{{ end }}
<!-- This here is a HTML comment. -->
<!-- This won't be visible on the rendered tab. -->
{{ if isset .Params "lorem" }}
Lorem is set to {{.Params.lorem}}.
{{ end }}
{{< /notebook-helper/notebook >}}
I take the {{ .Inner }}
as a string resource, then execute as template. Then produce three tabs:
-
The
.Inner
, fed into thehighlight
function (screenshot 1)
-
The resulting resource, inside
<pre><code>
tags (screenshot 2)
-
The resulting resource, as is (screenshot 3)
Comments / Questions / Feedback welcome!