diff --git a/layouts/simplecss/templates/pages_single.html b/layouts/simplecss/templates/pages_single.html new file mode 100644 index 0000000..6883c3e --- /dev/null +++ b/layouts/simplecss/templates/pages_single.html @@ -0,0 +1,2 @@ +{{ if .Page.Title }}
This is a test post
\n", "2026/02/20/another-post/index.html": "This is another test post
\n", "index.html": "Test Post,Another Post,", + "about/index.html": "About this site
\n", } outDir := t.TempDir() diff --git a/providers/sitebuilder/render_pages.go b/providers/sitebuilder/render_pages.go new file mode 100644 index 0000000..6183088 --- /dev/null +++ b/providers/sitebuilder/render_pages.go @@ -0,0 +1,31 @@ +package sitebuilder + +import ( + "bytes" + "context" + "html/template" + "io" +) + +func (b *Builder) renderPages(bctx buildContext) error { + for _, page := range b.site.Pages { + var md bytes.Buffer + if err := b.mdRenderer.RenderTo(context.Background(), &md, page.Body); err != nil { + return err + } + + data := pageSingleData{ + commonData: commonData{Site: b.site}, + Page: page, + HTML: template.HTML(md.String()), + } + + path := "/" + page.Slug + if err := b.createAtPath(bctx, path, func(f io.Writer) error { + return b.renderTemplate(f, tmplNamePageSingle, data) + }); err != nil { + return err + } + } + return nil +} diff --git a/providers/sitebuilder/tmpls.go b/providers/sitebuilder/tmpls.go index e0ece37..a0c8e34 100644 --- a/providers/sitebuilder/tmpls.go +++ b/providers/sitebuilder/tmpls.go @@ -26,6 +26,9 @@ const ( // tmplNameCategorySingle is the template for a single category page tmplNameCategorySingle = "categories_single.html" + + // tmplNamePageSingle is the template for a single page (pageSingleData) + tmplNamePageSingle = "pages_single.html" ) type Options struct { @@ -92,3 +95,9 @@ type categorySingleData struct { PrevURL string NextURL string } + +type pageSingleData struct { + commonData + Page *models.Page + HTML template.HTML +}