Skip to content

Commit

Permalink
return all available tags in /status.json
Browse files Browse the repository at this point in the history
Previously, tags that were not assigned to transcripts were not
available in the JSON because `.Site.Taxonomies.tags` returns
only tags that have been assigned to content/transcript.

To solve this, we create `all_tags.json` as part of the prebuild
step in order to have access to all the tags available from Optech.

This commit also switches the temporay source  from which we
were fetching the tags/topics as now we can get them directly
from "https://bitcoinops.org/topics.json"
  • Loading branch information
kouloumos committed Mar 6, 2024
1 parent c3a8390 commit bdb1d34
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
4 changes: 4 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ DefaultContentLanguage = "en"
source = "tags"
target = "content/tags"

[[module.mounts]]
source = "prebuild/public/data"
target = "data"

[languages]
[languages.en]
title = "₿itcoin Transcripts"
Expand Down
9 changes: 8 additions & 1 deletion prebuild/layouts/index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
{{ with resources.GetRemote "https://www.kouloumos.com/topics.json" }}
{{ with resources.GetRemote "https://bitcoinops.org/topics.json" }}
{{ $topics := unmarshal .Content }}
{{ $allTags := slice }} {{/* Initialize an empty slice to store all tags */}}
{{ range $topics }}
{{ $allTags = $allTags | append .slug }} {{/* Add the tag slug to the slice */}}
{{/* 1. */}} {{ $string := jsonify . }}
{{/* 2. */}} {{ $filename := printf "tags/%s/_index.md" (urlize .slug) }}
{{/* 3. */}} {{ $resource := resources.FromString $filename $string }}
{{/* 4. */}} {{ $file := $resource.RelPermalink }}
{{ end }}
{{/* Save the list of all tags to a data file */}}
{{ $dataFilename := "data/all_tags.json" }}
{{ $tagsString := jsonify $allTags }}
{{ $dataResource := resources.FromString $dataFilename $tagsString }}
{{ $dataFile := $dataResource.RelPermalink }}
{{ end }}
11 changes: 9 additions & 2 deletions themes/ace-documentation/layouts/_default/list.status.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
{{- $path := .Permalink -}}
{{- range $key, $value := $.Scratch.Get "missing" -}}
{{- if not (isset $params $key) -}}

{{- $.Scratch.SetInMap "missing" $key ($value | append $path) -}}
{{- end -}}
{{- end -}}
Expand All @@ -19,7 +18,6 @@
{{- $.Scratch.Add $lang 1 -}}
{{- end -}}
{{- end -}}

{{- end -}}

{{- $.Scratch.Set "transcripts" (dict "en" (len .Site.RegularPages) "es" ($.Scratch.Get "es") "pt" ($.Scratch.Get "pt") "zh" ($.Scratch.Get "zh")) -}}
Expand All @@ -32,10 +30,19 @@
{{ $speakerData = $speakerData | append .Page.LinkTitle }}
{{ end }}

{{/* First, add all taxonomy tags to tagData */}}
{{ range $tag, $not_used := .Site.Taxonomies.tags }}
{{ $tagData = $tagData | append $tag }}
{{ end }}

{{/* Then, add tags from the allTags.json file if they are not already included */}}
{{ $allTagsFromFile := (index .Site.Data.all_tags) | uniq }} {{/* Read and ensure unique tags from file */}}
{{ range $tagFromFile := $allTagsFromFile }}
{{ if not (in $tagData $tagFromFile) }}
{{ $tagData = $tagData | append $tagFromFile }}
{{ end }}
{{ end }}

{{ range $category, $not_used := .Site.Taxonomies.categories }}
{{ $categoryData = $categoryData | append $category }}
{{ end }}
Expand Down

0 comments on commit bdb1d34

Please sign in to comment.