all repos — homestead @ e4e8173ab6124daa84ef012e73c111f111d4a8cf

Code for my website

refactor: make templates take a more specific struct

Alan Pearce
commit

e4e8173ab6124daa84ef012e73c111f111d4a8cf

parent

a9f47f4e4ed3223e86dc1d5c3edd005b8d9ce589

1 file changed, 13 insertions(+), 7 deletions(-)

changed files
M templates/homepage.templtemplates/homepage.templ
@@ -5,9 +5,15 @@ "go.alanpearce.eu/homestead/internal/config"
"go.alanpearce.eu/homestead/internal/content" ) -templ Homepage(config *config.Config, posts []*content.Post, content templ.Component) { - @Layout(config, PageSettings{ - Title: config.Title, +type HomepageVars struct { + Email string + Me []config.MenuItem + Posts []*content.Post +} + +templ Homepage(site SiteSettings, vars HomepageVars, content templ.Component) { + @Layout(site, PageSettings{ + Title: site.Title, TitleAttrs: templ.Attributes{ "class": "p-name u-url", },
@@ -21,17 +27,17 @@ @content
</div> <section> <h2>Latest Posts</h2> - @list(posts[0:5]) + @list(vars.Posts[0:5]) </section> <section> <h2>Elsewhere on the Internet</h2> <ul class="elsewhere"> <li> - <a class="u-email" rel="me" href={ templ.SafeURL("mailto:" + config.Email) }> - { config.Email } + <a class="u-email" rel="me" href={ templ.SafeURL("mailto:" + vars.Email) }> + { vars.Email } </a> </li> - for _, link := range config.Menus["me"] { + for _, link := range vars.Me { <li> <a class="u-url" rel="me" href={ templ.SafeURL(link.URL.String()) }>{ link.Name }</a> </li>