Last active
May 21, 2022 20:45
-
-
Save cathelijne/cc7b3b00725f70605321b138dc16f2a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
As a beginner in Hugo and Golang, some stuff that looks simple takes a surprisingly long time to figure out. | |
I'm probably not the only one who tried to create a list of tags on a category page, or wondered if it's | |
possible to simply list everything in . in a simple manner. | |
I'll add more snippets as I go and learn more, and update the ones that can be done in a better way. | |
It's a loose collection, but maybe someone else has a use for these. | |
See also: | |
- https://github.com/cathelijne/hugo-theme-huguette, Huguette, a boilerplate theme to get you started and nothing more | |
- https://github.com/cathelijne/hugo-huguette-example, A one-click Netlify install of Hugo with Huguette as a theme | |
- https://github.com/cathelijne/hugo-dummy-content, Dummy content for Hugo: 100 pages in 5 sections with categories and tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ if or ($.Params.debug) ($.Site.Params.debug) }} | |
{{ $debugInfo := dict }} | |
{{ $debugSite := (.Site |jsonify|unmarshal) }} | |
{{ $debugSiteParams := (dict ".Params" .Site.Params) }} | |
{{ $debugSitePlusSiteParams := (dict ".Site" (merge $debugSite $debugSiteParams)) }} | |
{{ $debugParams := (dict ".Params" .Params) }} | |
{{ $debugPage := (dict ".Page" .Page) }} | |
{{ $debugDot := dict | |
".Aliases" .Aliases | |
".Date" .Date | |
".Description" .Description | |
".Draft" .Draft | |
".Keywords" .Keywords | |
".Kind" .Kind | |
".Layout" .Layout | |
".Name" .Name | |
".OutputFormats" .OutputFormats | |
".Permalink" .Permalink | |
".ReadingTime" .ReadingTime | |
".RelPermalink" .RelPermalink | |
".Resources" .Resources | |
".ResourceType" .ResourceType | |
".Summary" .Summary | |
".Section" .Section | |
".Title" .Title | |
".Type" .Type | |
".Weight" .Weight | |
".WordCount" .WordCount | |
}} | |
{{ $debugInfo := merge $debugSitePlusSiteParams $debugParams $debugDot}} | |
<div class="debug"> | |
<details class="card"> | |
<summary>Debug Info</summary> | |
<details class="card"> | |
<summary>All in one</summary> | |
<pre><code class="language-json" data-lang="json">{{ $debugInfo |jsonify (dict "indent" " ")}}</code></pre> | |
</details> | |
<details class="card"> | |
<summary>.Site</summary> | |
<pre><code class="language-json" data-lang="json">{{ $debugSite |jsonify (dict "indent" " ")}}</code></pre> | |
</details> | |
<details class="card"> | |
<summary>.Site.Params</summary> | |
<pre><code class="language-json" data-lang="json">{{ $debugSiteParams |jsonify (dict "indent" " ")}}</code></pre> | |
</details> | |
<details class="card"> | |
<summary>.Params</summary> | |
<pre><code class="language-json" data-lang="json">{{ $debugParams |jsonify (dict "indent" " ")}}</code></pre> | |
</details> | |
<details class="card"> | |
<summary>.</summary> | |
<pre><code class="language-json" data-lang="json">{{ $debugDot |jsonify (dict "indent" " ")}}</code></pre> | |
</details> | |
<details class="card"> | |
<summary>debug.Dump</summary> | |
<pre><code class="language-json" data-lang="json">{{ debug.Dump . }}</code></pre> | |
</details> | |
</div> | |
</div> | |
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Generate a content markdownfile with some extra frontmatter (introduction, categories, tags) | |
# Adapt to your liking | |
# Needs bash, curl, jq and sed | |
title=$(curl "https://asdfast.beobit.net/api/?type=word" |jq .text|sed 's/\.//') | |
subtitle=$(curl "https://asdfast.beobit.net/api/?type=word&length=9" |jq .text|sed 's/\.//g') | |
introduction=$(curl "https://asdfast.beobit.net/api/?type=paragraph&length=1" |jq .text) | |
clist=("Dolor" "Veritas" "Vino" "Canis" "Terra" "Domus") | |
tlist=("maecenas" "vitae" "rhoncus" "enim" "donec" "malesuada" "sem" "mollis" "neque" "pharetra" "sed" "cras" "ullamcorper" "semper" "sem" "vitae" "porta" "phasellus" "tincidunt" "tempor" "arcu " "eget" "porttitor" "orci" "vulputate" "amet" "urna" "congue" "volutpat" "sed" "velit" "etiam" "quis" "nibh" "porta" "imperdiet" "risus" "quis" "vehicula" "vivamus" "hendrerit") | |
tlist=( $(shuf -e "${tlist[@]}") ) | |
body=$(curl "https://jaspervdj.be/lorem-markdownum/markdown.txt?fenced-code-blocks=on&no-wrapping=on") | |
echo "---" | |
printf "date: %s\n" "$(date +%Y-%m-%dT%H:%M:%S)" | |
printf "title: %s\n" "$title" | |
printf "subtitle: %s\n" "$subtitle" | |
printf "introduction: %s\n" "$introduction" | |
printf "categories: [\"%s\"]\n" "$(shuf -e ${clist[@]} -n1)" | |
printf "tags: [\"%s\",\"%s\",\"%s\",\"%s\"]\n" "${tlist[@]:1:4}" | |
printf "debug: false\n" | |
printf "ignore: false\n" | |
printf "draft: false\n" | |
echo "---" | |
printf "%s\n" "$body" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment