diff options
Diffstat (limited to 'internal')
-rw-r--r-- | internal/builder/homepage.templ | 2 | ||||
-rw-r--r-- | internal/builder/page.templ | 11 | ||||
-rw-r--r-- | internal/config/config.go | 2 |
3 files changed, 12 insertions, 3 deletions
diff --git a/internal/builder/homepage.templ b/internal/builder/homepage.templ index df5bc32..848b9ed 100644 --- a/internal/builder/homepage.templ +++ b/internal/builder/homepage.templ @@ -33,7 +33,7 @@ templ homepage(config config.Config, posts []content.Post, content string) { </li> for _, link := range config.Menus["me"] { <li> - <a class="u-url" rel="me" href={ templ.SafeURL(link.URL) }>{ link.Name }</a> + <a class="u-url" rel="me" href={ templ.SafeURL(link.URL.String()) }>{ link.Name }</a> </li> } </ul> 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> diff --git a/internal/config/config.go b/internal/config/config.go index df69bce..4477ad4 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -16,7 +16,7 @@ type Taxonomy struct { type MenuItem struct { Name string - URL string `toml:"url"` + URL URL `toml:"url"` } type URL struct { |