added support for external links in main menu

This commit is contained in:
Oliver Obst 2023-03-04 18:45:17 +11:00
parent a9d7afe14c
commit a59eb2f896

View file

@ -2,6 +2,8 @@
{{ $headless := .Site.GetPage "/homepage" }} {{ $headless := .Site.GetPage "/homepage" }}
{{ $sections := $headless.Resources.ByType "page" }} {{ $sections := $headless.Resources.ByType "page" }}
{{ $sections := cond .Site.BuildDrafts $sections (where $sections "Draft" "==" false) }} {{ $sections := cond .Site.BuildDrafts $sections (where $sections "Draft" "==" false) }}
{{ $filtered := where $sections "Params.external" "==" nil }}
<header id="site-head" {{ with .Params.header_image }}style="background-image: url({{ . }})"{{ end }}> <header id="site-head" {{ with .Params.header_image }}style="background-image: url({{ . }})"{{ end }}>
<div class="vertical"> <div class="vertical">
<div id="site-head-content" class="inner"> <div id="site-head-content" class="inner">
@ -10,8 +12,12 @@
{{ with .Params.header_subheadline }}<h2 class="blog-description">{{ . }}</h2>{{ end }} {{ with .Params.header_subheadline }}<h2 class="blog-description">{{ . }}</h2>{{ end }}
{{ range where $sections ".Params.header_menu" "eq" true }} {{ range where $sections ".Params.header_menu" "eq" true }}
{{ if isset .Params "external" }}
<a class='btn site-menu' href='{{ .Params.external }}'>{{ .Title }}</a>
{{ else }}
<a class='btn site-menu' data-title-anchor='{{ anchorize .Title }}'>{{ .Title }}</a> <a class='btn site-menu' data-title-anchor='{{ anchorize .Title }}'>{{ .Title }}</a>
{{ end }} {{ end }}
{{ end }}
<i id='header-arrow' class="fa fa-angle-down"></i> <i id='header-arrow' class="fa fa-angle-down"></i>
</div> </div>
</div> </div>
@ -20,7 +26,7 @@
<div class='fixed-nav'> <div class='fixed-nav'>
</div> </div>
{{ range $index_val, $elem_val := $sections }} {{ range $index_val, $elem_val := $filtered }}
<div class='post-holder'> <div class='post-holder'>
<article id='{{ anchorize .Title }}' class='post {{ if eq $index_val 0 }}first{{ end }} {{ if eq (add $index_val 1) (len $sections) }}last{{ end }}'> <article id='{{ anchorize .Title }}' class='post {{ if eq $index_val 0 }}first{{ end }} {{ if eq (add $index_val 1) (len $sections) }}last{{ end }}'>
<header class="post-header"> <header class="post-header">