diff options
-rw-r--r-- | main.go | 22 |
1 files changed, 14 insertions, 8 deletions
@@ -61,6 +61,14 @@ type page struct { | |||
61 | 61 | ||
62 | type parts map[string][]byte | 62 | type parts map[string][]byte |
63 | 63 | ||
64 | func (p parts) clone() parts { | ||
65 | c := parts{} | ||
66 | for k, v := range p { | ||
67 | c[k] = v | ||
68 | } | ||
69 | return c | ||
70 | } | ||
71 | |||
64 | // Creates an initiated generator | 72 | // Creates an initiated generator |
65 | func newGenerator() (g generator) { | 73 | func newGenerator() (g generator) { |
66 | 74 | ||
@@ -192,19 +200,17 @@ func (g *generator) generate(page page) { | |||
192 | } | 200 | } |
193 | 201 | ||
194 | // Generate subpages in surdirectories | 202 | // Generate subpages in surdirectories |
195 | currentDirPath := page.dirPath | ||
196 | for _, dir := range dirs { | 203 | for _, dir := range dirs { |
197 | page.dirPath = path.Join(currentDirPath, dir) | 204 | subPage := page |
205 | subPage.dirPath = path.Join(page.dirPath, dir) | ||
206 | subPage.parts = page.parts.clone() | ||
198 | g.tasks.Add(1) | 207 | g.tasks.Add(1) |
199 | go g.generate(page) | 208 | go g.generate(subPage) |
200 | page.dirPath = currentDirPath | ||
201 | } | 209 | } |
202 | 210 | ||
203 | // Generate the page at the current directory | 211 | // Generate the page at the current directory |
204 | _, currentDir := path.Split(currentDirPath) | 212 | if _, currentDir := path.Split(page.dirPath); containsParsableFiles && !strings.HasPrefix(currentDir, g.skipPrefix) { |
205 | if containsParsableFiles && !strings.HasPrefix(currentDir, g.skipPrefix) { | 213 | fmt.Println("Rendering: " + page.dirPath) |
206 | fmt.Println("Rendering: " + currentDirPath) | ||
207 | |||
208 | page.body = []byte(mustache.Render(string(g.mergeParts(page.parts)), g.contextualize(page))) | 214 | page.body = []byte(mustache.Render(string(g.mergeParts(page.parts)), g.contextualize(page))) |
209 | err := fcmd.WriteFile(g.outputPath(path.Join(page.dirPath, g.saveAs)), page.body) | 215 | err := fcmd.WriteFile(g.outputPath(path.Join(page.dirPath, g.saveAs)), page.body) |
210 | if err != nil { | 216 | if err != nil { |