mirror of
				https://github.com/gohugoio/hugo.git
				synced 2024-05-11 05:54:58 +00:00 
			
		
		
		
	Adding an html file handler
This commit is contained in:
		| @@ -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} | ||||
| 	}, | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user