mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-28 22:19:59 +02:00
Allow non-markdown content in content directory
Allow content that is not markdown and does not need to be rendered to exists in the content directory. Currently any valid html or xml document can exist. Templates are applied to these documents as well. If you need to have content that doesn't have templates or AbsUrlify like operations, then continue to put this content in static and it will be copied over.
This commit is contained in:
@@ -90,8 +90,7 @@ func newPage(filename string) *Page {
|
||||
page := Page{contentType: "",
|
||||
File: File{FileName: filename, Extension: "html"},
|
||||
Node: Node{Keywords: make([]string, 10, 30)},
|
||||
Params: make(map[string]interface{}),
|
||||
Markup: "md"}
|
||||
Params: make(map[string]interface{})}
|
||||
page.Date, _ = time.Parse("20060102", "20080101")
|
||||
page.guessSection()
|
||||
return &page
|
||||
@@ -361,6 +360,18 @@ func (p *Page) ExecuteTemplate(layout string) *bytes.Buffer {
|
||||
return buffer
|
||||
}
|
||||
|
||||
func (page *Page) guessMarkupType() string {
|
||||
if page.Markup != "" {
|
||||
return page.Markup
|
||||
}
|
||||
|
||||
if strings.HasSuffix(page.FileName, ".md") {
|
||||
return "md"
|
||||
}
|
||||
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
func (page *Page) parse(reader io.Reader) error {
|
||||
p, err := parser.ReadFrom(reader)
|
||||
if err != nil {
|
||||
@@ -383,11 +394,15 @@ func (page *Page) parse(reader io.Reader) error {
|
||||
}
|
||||
}
|
||||
|
||||
switch page.Markup {
|
||||
case "md":
|
||||
switch page.guessMarkupType() {
|
||||
case "md", "markdown", "mdown":
|
||||
page.convertMarkdown(bytes.NewReader(p.Content()))
|
||||
case "rst":
|
||||
page.convertRestructuredText(bytes.NewReader(p.Content()))
|
||||
case "html":
|
||||
fallthrough
|
||||
default:
|
||||
page.Content = template.HTML(p.Content())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user