devtools/hackdoc: propagate ref in imgs and redirects

Change-Id: Ideb2a8f10f8193cd782b0e1d913e7aa99bbfa52f
This commit is contained in:
q3k 2020-04-13 01:35:33 +02:00
parent b180a145d4
commit 4b4a33a693
2 changed files with 2 additions and 2 deletions

View file

@ -205,7 +205,7 @@ func (r *request) handlePageAuto(dirpath string) {
}
if file {
http.Redirect(r.w, r.r, "/"+fpath, 302)
http.Redirect(r.w, r.r, "/"+fpath+"?ref="+r.ref, 302)
return
}
}

View file

@ -27,7 +27,7 @@ func renderMarkdown(input []byte, ref string) []byte {
r.RenderHeader(&buf, ast)
buf.Write([]byte(`</div><div class="content">`))
ast.Walk(func(node *blackfriday.Node, entering bool) blackfriday.WalkStatus {
if ref != "" && entering && node.Type == blackfriday.Link {
if ref != "" && entering && node.Type == blackfriday.Link || node.Type == blackfriday.Image {
dest := string(node.Destination)
u, err := url.Parse(dest)
if err == nil && !u.IsAbs() {