mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Handlers WIP (builds)
This commit is contained in:
parent
93f3d604c6
commit
30d4a26ba0
3 changed files with 9 additions and 10 deletions
|
@ -24,7 +24,7 @@ var Pager interface {
|
|||
|
||||
var markdown = Handle{
|
||||
extensions: []string{"mdown", "markdown", "md"},
|
||||
readrun: func(f *source.File, results HandleResults) {
|
||||
readrun: func(f *source.File, s *Site, results HandleResults) {
|
||||
page, err := NewPage(f.Path())
|
||||
if err != nil {
|
||||
results <- HandledResult{file: f, err: err}
|
||||
|
@ -34,6 +34,9 @@ var markdown = Handle{
|
|||
results <- HandledResult{file: f, err: err}
|
||||
}
|
||||
|
||||
page.Site = &s.Info
|
||||
page.Tmpl = s.Tmpl
|
||||
|
||||
results <- HandledResult{file: f, page: page, err: err}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ package hugolib
|
|||
import "github.com/spf13/hugo/source"
|
||||
|
||||
type Handler interface {
|
||||
Read(*source.File, HandleResults)
|
||||
Read(*source.File, *Site, HandleResults)
|
||||
//Render()
|
||||
//Convert()
|
||||
Extensions() []string
|
||||
|
@ -30,7 +30,7 @@ type HandledResult struct {
|
|||
|
||||
type HandleResults chan<- HandledResult
|
||||
|
||||
type ReadFunc func(*source.File, HandleResults)
|
||||
type ReadFunc func(*source.File, *Site, HandleResults)
|
||||
|
||||
type Handle struct {
|
||||
extensions []string
|
||||
|
@ -43,8 +43,8 @@ func (h Handle) Extensions() []string {
|
|||
return h.extensions
|
||||
}
|
||||
|
||||
func (h Handle) Read(s *source.File, results HandleResults) {
|
||||
h.readrun(s, results)
|
||||
func (h Handle) Read(f *source.File, s *Site, results HandleResults) {
|
||||
h.readrun(f, s, results)
|
||||
}
|
||||
|
||||
func RegisterHandler(h Handler) {
|
||||
|
|
|
@ -402,14 +402,10 @@ func sourceReader(s *Site, files <-chan *source.File, results chan<- HandledResu
|
|||
for file := range files {
|
||||
h := FindHandler(file.Extension())
|
||||
if h != nil {
|
||||
h.Read(file, results)
|
||||
h.Read(file, s, results)
|
||||
} else {
|
||||
jww.ERROR.Println("Unsupported File Type", file.Path())
|
||||
}
|
||||
|
||||
// TODO: Figure out Site stuff
|
||||
//page.Site = &s.Info
|
||||
//page.Tmpl = s.Tmpl
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue