all repos — homestead @ ea267852dae599821d1cb4b2bc60dd3f37a83d41

Code for my website

update htmlformat

Alan Pearce
commit

ea267852dae599821d1cb4b2bc60dd3f37a83d41

parent

76541a74e24edf3c461141cfd88cadb93beb7008

1 file changed, 51 insertions(+), 64 deletions(-)

changed files
M domain/web/templates/layout.godomain/web/templates/layout.go
@@ -5,8 +5,8 @@ "io"
g "alin.ovh/gomponents" . "alin.ovh/gomponents/html" + "alin.ovh/htmlformat" "github.com/Southclaws/fault" - "github.com/alanpearce/htmlformat" "alin.ovh/homestead/shared/config" )
@@ -51,60 +51,61 @@ })
} func Layout(site SiteSettings, page PageSettings, children ...g.Node) g.NodeWriter { - return DoctypeHTML(FormattedDocument( - HTML( - Lang(site.Language), - Head( - Meta(Name("viewport"), Content("width=device-width, initial-scale=1.0")), - TitleEl(g.Text(page.Title)), - Link( - Rel("stylesheet"), - Type("text/css"), - Href("/style.css"), - ), - Link( - Rel("alternate"), - Type("application/atom+xml"), - Title(site.Title), - Href("/atom.xml"), + return FormattedDocument( + Doctype( + HTML( + Lang(site.Language), + Head( + Meta(Name("viewport"), Content("width=device-width, initial-scale=1.0")), + TitleEl(g.Text(page.Title)), + Link( + Rel("stylesheet"), + Type("text/css"), + Href("/style.css"), + ), + Link( + Rel("alternate"), + Type("application/atom+xml"), + Title(site.Title), + Href("/atom.xml"), + ), + g.Group(page.HeadExtra), ), - g.Group(page.HeadExtra), - ), - Body( - ExtendAttrs(page.BodyAttrs, nil), - A(Class("skip"), Href("#main"), g.Text("Skip to main content")), - Header( - H2( + Body( + ExtendAttrs(page.BodyAttrs, nil), + A(Class("skip"), Href("#main"), g.Text("Skip to main content")), + Header( + H2( + A( + ExtendAttrs(Attrs{ + "class": "title p-name", + "href": "/", + }, page.TitleAttrs), + g.Text(site.Title)), + ), + Nav( + g.Map(site.Menu, MenuLink), + ), + ), + Main(ID("main"), g.Group(children)), + Footer( + A(Href("https://git.alin.ovh/website"), g.Text("Content")), + g.Text(" is "), A( - ExtendAttrs(Attrs{ - "class": "title p-name", - "href": "/", - }, page.TitleAttrs), - g.Text(site.Title)), + Rel("license"), + Href("http://creativecommons.org/licenses/by/4.0/"), + g.Text("CC BY 4.0"), + ), + g.Text(". "), + A(Href("https://git.alin.ovh/homestead"), g.Text("Site source code")), + g.Text(" is "), + A(Href("https://opensource.org/licenses/MIT"), g.Text("MIT")), ), - Nav( - g.Map(site.Menu, MenuLink), + g.If(site.InjectLiveReload, + LiveReload, ), ), - Main(ID("main"), g.Group(children)), - Footer( - A(Href("https://git.alin.ovh/website"), g.Text("Content")), - g.Text(" is "), - A( - Rel("license"), - Href("http://creativecommons.org/licenses/by/4.0/"), - g.Text("CC BY 4.0"), - ), - g.Text(". "), - A(Href("https://git.alin.ovh/homestead"), g.Text("Site source code")), - g.Text(" is "), - A(Href("https://opensource.org/licenses/MIT"), g.Text("MIT")), - ), - g.If(site.InjectLiveReload, - LiveReload, - ), - ), - ))) + ))) } func MenuLink(item config.MenuItem) g.Node {
@@ -131,17 +132,3 @@
return 0, nil }) } - -func DoctypeHTML(sibling g.Node) g.NodeWriter { - return g.NodeWriterFunc(func(w io.Writer) (int64, error) { - if _, err := w.Write([]byte("<!doctype html>\n")); err != nil { - return 0, err - } - - if sibling, ok := sibling.(g.NodeWriter); ok { - return sibling.WriteTo(w) - } - - return 0, sibling.Render(w) - }) -}