diff --git a/main.go b/main.go index 62b8ad7..5ed93ba 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "bytes" "flag" "html/template" "io/ioutil" @@ -76,5 +77,18 @@ func servePage(w http.ResponseWriter, r *http.Request) { return } - t.Execute(w, template.HTML(blackfriday.MarkdownCommon(c))) + var title string + if idx := bytes.IndexByte(c, '\n'); idx != -1 { + fl := string(c[:idx]) + if strings.HasPrefix(fl, `[title]:`) { + title = strings.TrimPrefix(fl, `[title]:`) + } + } + + data := struct { + Title string + Content template.HTML + }{title, template.HTML(blackfriday.MarkdownCommon(c))} + + t.Execute(w, data) }