diff options
author | Alan Pearce | 2024-06-19 13:51:24 +0200 |
---|---|---|
committer | Alan Pearce | 2024-06-19 14:10:44 +0200 |
commit | 8002766378b1153e749297ed1d01ba221ee72b41 (patch) | |
tree | 070039ee0b76ea576791418f72e76e95c2c5e7ab /internal/builder/page.templ | |
parent | 45a2e290aa2bc59deb5971255accba517500cc25 (diff) | |
download | website-8002766378b1153e749297ed1d01ba221ee72b41.tar.lz website-8002766378b1153e749297ed1d01ba221ee72b41.tar.zst website-8002766378b1153e749297ed1d01ba221ee72b41.zip |
style external nav menu links
Diffstat (limited to 'internal/builder/page.templ')
-rw-r--r-- | internal/builder/page.templ | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/internal/builder/page.templ b/internal/builder/page.templ index 7b3380f..9a2be2f 100644 --- a/internal/builder/page.templ +++ b/internal/builder/page.templ @@ -20,6 +20,15 @@ func extendClasses(cs string, attrs templ.Attributes) string { } } +templ menuItem(item config.MenuItem) { + <a + href={ templ.SafeURL(item.URL.String()) } + if item.URL.IsAbs() { + target="_blank" + } + >{ item.Name }</a> +} + templ page(site config.Config, page PageSettings) { <!DOCTYPE html> <html lang={ site.DefaultLanguage }> @@ -38,7 +47,7 @@ templ page(site config.Config, page PageSettings) { </h2> <nav> for _, item := range site.Menus["main"] { - <a href={ templ.SafeURL(item.URL) }>{ item.Name }</a> + @menuItem(item) } </nav> </header> |