mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-27 20:22:15 +00:00
Adding an html file handler
This commit is contained in:
parent
7fba250023
commit
ade2ca6072
1 changed files with 31 additions and 2 deletions
|
@ -16,10 +16,11 @@ package hugolib
|
|||
import "github.com/spf13/hugo/source"
|
||||
|
||||
func init() {
|
||||
RegisterHandler(markdown)
|
||||
RegisterHandler(markdownHandler)
|
||||
RegisterHandler(htmlHandler)
|
||||
}
|
||||
|
||||
var markdown = Handle{
|
||||
var markdownHandler = Handle{
|
||||
extensions: []string{"mdown", "markdown", "md"},
|
||||
read: func(f *source.File, s *Site, results HandleResults) {
|
||||
page, err := NewPage(f.Path())
|
||||
|
@ -46,3 +47,31 @@ var markdown = Handle{
|
|||
results <- HandledResult{err: err}
|
||||
},
|
||||
}
|
||||
|
||||
var htmlHandler = Handle{
|
||||
extensions: []string{"html", "htm"},
|
||||
read: func(f *source.File, s *Site, results HandleResults) {
|
||||
page, err := NewPage(f.Path())
|
||||
if err != nil {
|
||||
results <- HandledResult{file: f, err: err}
|
||||
}
|
||||
|
||||
if err := page.ReadFrom(f.Contents); err != nil {
|
||||
results <- HandledResult{file: f, err: err}
|
||||
}
|
||||
|
||||
page.Site = &s.Info
|
||||
page.Tmpl = s.Tmpl
|
||||
|
||||
results <- HandledResult{file: f, page: page, err: err}
|
||||
},
|
||||
pageConvert: func(p *Page, s *Site, results HandleResults) {
|
||||
p.ProcessShortcodes(s.Tmpl)
|
||||
err := p.Convert()
|
||||
if err != nil {
|
||||
results <- HandledResult{err: err}
|
||||
}
|
||||
|
||||
results <- HandledResult{err: err}
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue