mirror of
https://github.com/gohugoio/hugo.git
synced 2025-03-19 11:43:04 +00: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{
|
var markdown = Handle{
|
||||||
extensions: []string{"mdown", "markdown", "md"},
|
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())
|
page, err := NewPage(f.Path())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
results <- HandledResult{file: f, err: err}
|
results <- HandledResult{file: f, err: err}
|
||||||
|
@ -34,6 +34,9 @@ var markdown = Handle{
|
||||||
results <- HandledResult{file: f, err: err}
|
results <- HandledResult{file: f, err: err}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
page.Site = &s.Info
|
||||||
|
page.Tmpl = s.Tmpl
|
||||||
|
|
||||||
results <- HandledResult{file: f, page: page, err: err}
|
results <- HandledResult{file: f, page: page, err: err}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ package hugolib
|
||||||
import "github.com/spf13/hugo/source"
|
import "github.com/spf13/hugo/source"
|
||||||
|
|
||||||
type Handler interface {
|
type Handler interface {
|
||||||
Read(*source.File, HandleResults)
|
Read(*source.File, *Site, HandleResults)
|
||||||
//Render()
|
//Render()
|
||||||
//Convert()
|
//Convert()
|
||||||
Extensions() []string
|
Extensions() []string
|
||||||
|
@ -30,7 +30,7 @@ type HandledResult struct {
|
||||||
|
|
||||||
type HandleResults chan<- HandledResult
|
type HandleResults chan<- HandledResult
|
||||||
|
|
||||||
type ReadFunc func(*source.File, HandleResults)
|
type ReadFunc func(*source.File, *Site, HandleResults)
|
||||||
|
|
||||||
type Handle struct {
|
type Handle struct {
|
||||||
extensions []string
|
extensions []string
|
||||||
|
@ -43,8 +43,8 @@ func (h Handle) Extensions() []string {
|
||||||
return h.extensions
|
return h.extensions
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h Handle) Read(s *source.File, results HandleResults) {
|
func (h Handle) Read(f *source.File, s *Site, results HandleResults) {
|
||||||
h.readrun(s, results)
|
h.readrun(f, s, results)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterHandler(h Handler) {
|
func RegisterHandler(h Handler) {
|
||||||
|
|
|
@ -402,14 +402,10 @@ func sourceReader(s *Site, files <-chan *source.File, results chan<- HandledResu
|
||||||
for file := range files {
|
for file := range files {
|
||||||
h := FindHandler(file.Extension())
|
h := FindHandler(file.Extension())
|
||||||
if h != nil {
|
if h != nil {
|
||||||
h.Read(file, results)
|
h.Read(file, s, results)
|
||||||
} else {
|
} else {
|
||||||
jww.ERROR.Println("Unsupported File Type", file.Path())
|
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