hugo docshelper 源码

  • 2022-10-23
  • 浏览 (507)

hugo docshelper 代码

文件路径:/helpers/docshelper.go

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() {
	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)

		}

		return docshelper.DocProvider{"chroma": map[string]any{"lexers": chromaLexers}}
	}

	docshelper.AddDocProviderFunc(docsProvider)
}

相关信息

hugo 源码目录

相关文章

hugo content 源码

hugo emoji 源码

hugo general 源码

hugo path 源码

hugo pathspec 源码

hugo processing_stats 源码

hugo url 源码

0  赞