hugo/helpers/docshelper.go

38 lines
723 B
Go
Raw Normal View History

package helpers
import (
"sort"
"github.com/alecthomas/chroma/v2/lexers"
"github.com/gohugoio/hugo/docshelper"
)
// This is is just some helpers used to create some JSON used in the Hugo docs.
func init() {
2020-03-20 15:34:53 +00:00
docsProvider := func() docshelper.DocProvider {
var chromaLexers []any
sort.Sort(lexers.GlobalLexerRegistry.Lexers)
for _, l := range lexers.GlobalLexerRegistry.Lexers {
config := l.Config()
lexerEntry := struct {
Name string
Aliases []string
}{
config.Name,
config.Aliases,
}
chromaLexers = append(chromaLexers, lexerEntry)
}
2020-03-20 15:34:53 +00:00
return docshelper.DocProvider{"chroma": map[string]any{"lexers": chromaLexers}}
}
2020-03-20 15:34:53 +00:00
docshelper.AddDocProviderFunc(docsProvider)
}