From e2d66e3218e180bbfca06ca3a29ce01957c513e9 Mon Sep 17 00:00:00 2001 From: Bjørn Erik Pedersen Date: Sun, 17 Mar 2024 11:12:33 +0100 Subject: Create pages from _content.gotmpl Closes #12427 Closes #12485 Closes #6310 Closes #5074 --- markup/markup.go | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'markup/markup.go') diff --git a/markup/markup.go b/markup/markup.go index 835c7bbec..cd1c1f823 100644 --- a/markup/markup.go +++ b/markup/markup.go @@ -19,6 +19,7 @@ import ( "strings" "github.com/gohugoio/hugo/markup/highlight" + "github.com/gohugoio/hugo/media" "github.com/gohugoio/hugo/markup/markup_config" @@ -44,7 +45,7 @@ func NewConverterProvider(cfg converter.ProviderConfig) (ConverterProvider, erro defaultHandler := mcfg.DefaultMarkdownHandler var defaultFound bool - add := func(p converter.ProviderProvider, aliases ...string) error { + add := func(p converter.ProviderProvider, subType string, aliases ...string) error { c, err := p.New(cfg) if err != nil { return err @@ -53,6 +54,7 @@ func NewConverterProvider(cfg converter.ProviderConfig) (ConverterProvider, erro name := c.Name() aliases = append(aliases, name) + aliases = append(aliases, subType) if strings.EqualFold(name, defaultHandler) { aliases = append(aliases, "markdown") @@ -63,19 +65,21 @@ func NewConverterProvider(cfg converter.ProviderConfig) (ConverterProvider, erro return nil } - if err := add(goldmark.Provider); err != nil { + contentTypes := cfg.Conf.ContentTypes().(media.ContentTypes) + + if err := add(goldmark.Provider, contentTypes.Markdown.SubType, contentTypes.Markdown.Suffixes()...); err != nil { return nil, err } - if err := add(asciidocext.Provider, "ad", "adoc"); err != nil { + if err := add(asciidocext.Provider, contentTypes.AsciiDoc.SubType, contentTypes.AsciiDoc.Suffixes()...); err != nil { return nil, err } - if err := add(rst.Provider); err != nil { + if err := add(rst.Provider, contentTypes.ReStructuredText.SubType, contentTypes.ReStructuredText.Suffixes()...); err != nil { return nil, err } - if err := add(pandoc.Provider, "pdc"); err != nil { + if err := add(pandoc.Provider, contentTypes.Pandoc.SubType, contentTypes.Pandoc.Suffixes()...); err != nil { return nil, err } - if err := add(org.Provider); err != nil { + if err := add(org.Provider, contentTypes.EmacsOrgMode.SubType, contentTypes.EmacsOrgMode.Suffixes()...); err != nil { return nil, err } @@ -133,3 +137,16 @@ func addConverter(m map[string]converter.Provider, c converter.Provider, aliases m[alias] = c } } + +// ResolveMarkup returns the markup type. +func ResolveMarkup(s string) string { + s = strings.ToLower(s) + switch s { + case "goldmark": + return media.DefaultContentTypes.Markdown.SubType + case "asciidocext": + return media.DefaultContentTypes.AsciiDoc.SubType + default: + return s + } +} -- cgit v1.2.3