Skip to content

Commit dd62d11

Browse files
committed
add funcs in layout too
1 parent c44b78a commit dd62d11

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

render.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/microcosm-cc/bluemonday"
2121
cp "github.com/otiai10/copy"
2222
"github.com/sabloger/sitemap-generator/smg"
23+
"github.com/samber/lo"
2324
"github.com/tdewolff/minify"
2425
mHTML "github.com/tdewolff/minify/html"
2526
"github.com/yuin/goldmark"
@@ -315,11 +316,12 @@ func (r *Render) renderDocument(doc *Doc, funcMap template.FuncMap, layout *temp
315316

316317
layoutWriter := &bytes.Buffer{}
317318

318-
err = layout.Execute(layoutWriter, map[string]any{
319-
"Doc": doc,
320-
321-
"RenderedPage": renderedMarkdown,
322-
})
319+
err = layout.Execute(layoutWriter, lo.Assign(
320+
funcMap,
321+
map[string]any{
322+
"Doc": doc,
323+
"RenderedPage": renderedMarkdown,
324+
}))
323325
if err != nil {
324326
return fmt.Errorf("could not render layout template (%s): %w", doc.Filename(), err)
325327
}

0 commit comments

Comments
 (0)