In jekyll you insert this at the top of your markdown and are able to insert them into your layouts:
---
layout: post
title: Blogging Like a Hacker
---
I need to do the same in Go using no frameworks or fancy packages. Just Golang.
import (
"github.com/russross/blackfriday"
"html/template"
"io/ioutil"
"net/http"
)
type webPost struct {
Title string
Author string
Description string
Body template.HTML
}
func handlePost(res http.ResponseWriter, req *http.Request) {
//Read in some markdown from a file
input, _ := ioutil.ReadFile("test.md")
//Render it into HTML
output := blackfriday.MarkdownCommon(input)
//I need the first three parameters to grab the front matter from test.md
post := webPost{"title", "author", "a descritpion", template.HTML(output)}
//Serve to client a template
templates.ExecuteTemplate(res, "Post", post)
}