aboutsummaryrefslogtreecommitdiff
path: root/page/page.go
diff options
context:
space:
mode:
Diffstat (limited to 'page/page.go')
-rw-r--r--page/page.go31
1 files changed, 27 insertions, 4 deletions
diff --git a/page/page.go b/page/page.go
index 47e64e3..3c6a130 100644
--- a/page/page.go
+++ b/page/page.go
@@ -3,22 +3,23 @@ package page
import (
"bufio"
"bytes"
+ "fmt"
"io"
"os"
"text/template"
"time"
- "gopkg.in/russross/blackfriday.v2"
+ "github.com/russross/blackfriday"
"gopkg.in/yaml.v2"
)
type Page struct {
Name string
Head string
- Body string
Date *time.Time
Published bool
- Templates map[string]string
+ Vars map[string]interface{}
+ Markdown []byte
}
// Can be adjusted to change the base template used in rendering
@@ -94,6 +95,28 @@ func (p *Page) Read() error {
return err
}
- p.Body = string(blackfriday.Run(markdownBuf.Bytes()))
+ // p.Body = string(blackfriday.Run(markdownBuf.Bytes()))
+ p.Markdown = markdownBuf.Bytes()
return nil
}
+
+func (p *Page) RenderBody() (string, error) {
+ buf := &bytes.Buffer{}
+ t, err := template.New("Body").Parse(string(p.Markdown))
+ if err != nil {
+ return "", err
+ }
+
+ err = t.Execute(buf, p)
+ if err != nil {
+ return "", err
+ }
+
+ return string(blackfriday.Run(buf.Bytes())), nil
+
+ // return buf.String(), nil
+}
+
+func (p Page) String() string {
+ return fmt.Sprintf("Page: %s", p.Name)
+}