Commit 32b8857e authored by Matt Holt's avatar Matt Holt

Merge pull request #461 from abiosoft/markdown-sitegen-panic

markdown: Fix panic on sitegen for request dependent template values.
parents c748ef94 9e163a65
...@@ -5,6 +5,8 @@ import ( ...@@ -5,6 +5,8 @@ import (
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net/http"
"net/url"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
...@@ -103,8 +105,12 @@ func generateStaticHTML(md Markdown, cfg *Config) error { ...@@ -103,8 +105,12 @@ func generateStaticHTML(md Markdown, cfg *Config) error {
reqPath = filepath.ToSlash(reqPath) reqPath = filepath.ToSlash(reqPath)
reqPath = "/" + reqPath reqPath = "/" + reqPath
// Create empty requests and url to cater for template values.
req, _ := http.NewRequest("", "/", nil)
urlVar, _ := url.Parse("/")
// Generate the static file // Generate the static file
ctx := middleware.Context{Root: md.FileSys} ctx := middleware.Context{Root: md.FileSys, Req: req, URL: urlVar}
_, err = md.Process(cfg, reqPath, body, ctx) _, err = md.Process(cfg, reqPath, body, ctx)
if err != nil { if err != nil {
return err return err
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment