diff --git a/main.go b/main.go
index 206d02d..5050dc6 100644
--- a/main.go
+++ b/main.go
@@ -38,15 +38,22 @@ func (n *Node) writeIndex(w io.Writer) {
{{ end }}
{{ end }}
-
- {{ template "tree" . }}
+
+
+
+
+
+
+
+ {{ template "tree" . }}
+
`)
if err != nil {
@@ -84,13 +91,28 @@ func (n *Node) addChild(child *Node) {
}
func writeHTML(n *Node) {
+ os.Chdir("pages")
f, err := os.Create(n.Data.Id + ".html")
if err != nil {
log.Fatalf("Error creating file for ID %v", n.Data.Id)
}
defer f.Close()
- log.Printf("Writing file %v", f.Name())
- f.Write([]byte(n.Data.Body))
+ log.Printf("Writing file %v containing page: %v", f.Name(), n.Data.Title)
+ html := `
+
+
+
+
+
+
+
+ `
+ html += n.Data.Body
+ html += ""
+ _, err = f.Write([]byte(html))
+ if err != nil {
+ log.Fatalf("Error writing file for ID %v", n.Data.Id)
+ }
}
type spaceResult struct {
@@ -310,6 +332,9 @@ func main() {
root := createPageTree(&result)
fname := "index.html"
+ os.Mkdir("content", 0744)
+ os.Mkdir("content/pages", 0744)
+ os.Chdir("content")
f, err := os.Create(fname)
if err != nil {
log.Fatalf("Failed to open %v", fname)