package gallery
import (
"bytes"
"html/template"
)
// The Overview: the address every visitor lands on first. Its intro;
// then the demo application, framed, because what a first-time reader
// wants to know is what an app built with this looks like; then a
// route into each of the other pages, read off pageKinds() with each
// row's own blurb, so a page kind appears here the day its row lands.
const overviewBody = `{{define "ds-body-overview"}}
{{say "gallery.overview.intro"}}
{{say "gallery.overview.next"}}
{{end}}`
// overviewBody renders the Overview's body for p: the page, with the
// demo's widget and address beside it.
func (s *site) overviewBody(p page) (template.HTML, error) {
return s.body(p.Locale, "ds-body-overview", struct {
page
Demo previewView
DemoHref string
}{p, s.demoView(p), s.demoHref(p.Theme, p.Locale)})
}
// body executes one named body template against data.
func (s *site) body(locale, name string, data any) (template.HTML, error) {
t, err := s.templates(locale)
if err != nil {
return "", err
}
var b bytes.Buffer
if err := t.ExecuteTemplate(&b, name, data); err != nil {
return "", err
}
return template.HTML(b.String()), nil
}
func init() { registerTemplate(overviewBody) }