martijn
/
hugo-gopher
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2020-07-09. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
Aller au fichier
Martijn de Boer e2400258c0 Update config 2019-01-07 21:40:30 +01:00
README.md Rename readme 2019-01-07 21:39:10 +01:00
app.js Watch JSON file for changes 2019-01-05 20:36:49 +01:00
configuration.json Update config 2019-01-07 21:40:30 +01:00

README.md

Reads a flat JSON file and makes it publishable as a gophermenu. The configuration options speak for themselves.

Just a quick script. It should be better at some point.

TODO

  • add directories
  • add sorting

If you use Hugo as my intended purpose for this script, add JSON to your TOML configuration.

[outputs]
	home = ["HTML","RSS","JSON"]

And create a JSON output in your theme folder called index.json:

{{- $.Scratch.Add "index" slice -}}
{{- range .Site.RegularPages -}}
    {{- $.Scratch.Add "index" (dict "title" .Title "body" .Plain "id" .Permalink) -}}
{{- end -}}
{{- $.Scratch.Get "index" | jsonify -}}

The json format should be like this:

[
	{
		"body": "Textual contents of item 1",
		"title": "Item 1",
		"uri": "/items/1"
	},
	{
		"body": "Textual contents of item 2",
		"title": "Item 2",
		"uri": "/items/2"
	},
]

This removes a bit of formatting too agressively but alas.

LICENSE; Just give some attribution and do what you want with this.

Also let me know @sexybiggetje@mastodon.social if you want me to check it out.