mirror of
https://github.com/gohugoio/hugo.git
synced 2025-03-24 23:02:03 +00:00
Adding Planner
This commit is contained in:
parent
79d9f82e79
commit
13d2c55206
3 changed files with 43 additions and 4 deletions
9
hugolib/planner.go
Normal file
9
hugolib/planner.go
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
package hugolib
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s *Site) ShowPlan(out io.Writer) (err error) {
|
||||||
|
return
|
||||||
|
}
|
|
@ -47,6 +47,23 @@ func PrintErr(str string, a ...interface{}) {
|
||||||
fmt.Fprintln(os.Stderr, str, a)
|
fmt.Fprintln(os.Stderr, str, a)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Site contains all the information relevent for constructing a static
|
||||||
|
// site. The basic flow of information is as follows:
|
||||||
|
//
|
||||||
|
// 1. A list of Files is parsed and then converted into Pages.
|
||||||
|
//
|
||||||
|
// 2. Pages contain sections (based on the file they were generated from),
|
||||||
|
// aliases and slugs (included in a pages frontmatter) which are the
|
||||||
|
// various targets that will get generated. There will be canonical
|
||||||
|
// listing.
|
||||||
|
//
|
||||||
|
// 3. Indexes are created via configuration and will present some aspect of
|
||||||
|
// the final page and typically a perm url.
|
||||||
|
//
|
||||||
|
// 4. All Pages are passed through a template based on their desired
|
||||||
|
// layout based on numerous different elements.
|
||||||
|
//
|
||||||
|
// 5. The entire collection of files is written to disk.
|
||||||
type Site struct {
|
type Site struct {
|
||||||
Config Config
|
Config Config
|
||||||
Pages Pages
|
Pages Pages
|
||||||
|
@ -85,10 +102,9 @@ func (s *Site) Build() (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err = s.Render(); err != nil {
|
if err = s.Render(); err != nil {
|
||||||
fmt.Printf("Error rendering site: %s\n", err)
|
fmt.Printf("Error rendering site: %s\nAvailable templates:\n", err)
|
||||||
fmt.Printf("Available templates:")
|
for _, template := range s.Tmpl.Templates() {
|
||||||
for _, tpl := range s.Tmpl.Templates() {
|
fmt.Printf("\t%s\n", template.Name())
|
||||||
fmt.Printf("\t%s\n", tpl.Name())
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
14
hugolib/site_show_plan_test.go
Normal file
14
hugolib/site_show_plan_test.go
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
package hugolib
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestDegenerateNoTarget(t *testing.T) {
|
||||||
|
s := new(Site)
|
||||||
|
out := new(bytes.Buffer)
|
||||||
|
if err := s.ShowPlan(out); err != nil {
|
||||||
|
t.Errorf("ShowPlan unexpectedly returned an error: %s", err)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue