diff options
| author | a73x <[email protected]> | 2024-09-03 08:52:12 +0100 |
|---|---|---|
| committer | a73x <[email protected]> | 2024-09-03 08:52:12 +0100 |
| commit | 17b008f72f284ea989fddb2b6b52c2ca558c985a (patch) | |
| tree | acb286b07dd62fc0e539ae466536132b3c9b7c94 /pages | |
| parent | 1c0e1cc8c6a51457907ce028599c2bcad82d0bfd (diff) | |
chore(html): refactor nav to be more dynamic
Diffstat (limited to 'pages')
| -rw-r--r-- | pages/pages.go | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/pages/pages.go b/pages/pages.go index 63c3432..2caa866 100644 --- a/pages/pages.go +++ b/pages/pages.go @@ -12,6 +12,7 @@ import ( type GlobalState struct { Collections map[string][]markdown.Content + Nav map[string]markdown.Content } type ParserPair struct { @@ -67,21 +68,25 @@ func Collect() ([]Page, error) { Collections: map[string][]markdown.Content{ "all": contents, }, + Nav: map[string]markdown.Content{}, } for _, content := range contents { tags, ok := content.Meta["tags"] - if !ok { - continue + if ok { + switch tags := tags.(type) { + case string: + gs.Collections[tags] = append(gs.Collections[tags], content) + case []string: + for _, tag := range tags { + gs.Collections[tag] = append(gs.Collections[tag], content) + } + } } - switch tags := tags.(type) { - case string: - gs.Collections[tags] = append(gs.Collections[tags], content) - case []string: - for _, tag := range tags { - gs.Collections[tag] = append(gs.Collections[tag], content) - } + nav, ok := content.Meta["nav"] + if ok { + gs.Nav[nav.(string)] = content } } |
