Skip to content

Commit

Permalink
add funcs in layout too
Browse files Browse the repository at this point in the history
  • Loading branch information
jtarchie committed Jan 24, 2024
1 parent c44b78a commit dd62d11
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions render.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/microcosm-cc/bluemonday"
cp "github.com/otiai10/copy"
"github.com/sabloger/sitemap-generator/smg"
"github.com/samber/lo"
"github.com/tdewolff/minify"
mHTML "github.com/tdewolff/minify/html"
"github.com/yuin/goldmark"
Expand Down Expand Up @@ -315,11 +316,12 @@ func (r *Render) renderDocument(doc *Doc, funcMap template.FuncMap, layout *temp

layoutWriter := &bytes.Buffer{}

err = layout.Execute(layoutWriter, map[string]any{
"Doc": doc,

"RenderedPage": renderedMarkdown,
})
err = layout.Execute(layoutWriter, lo.Assign(
funcMap,
map[string]any{
"Doc": doc,
"RenderedPage": renderedMarkdown,
}))
if err != nil {
return fmt.Errorf("could not render layout template (%s): %w", doc.Filename(), err)
}
Expand Down

0 comments on commit dd62d11

Please sign in to comment.