Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal links on site head #158

Merged
merged 12 commits into from
Oct 14, 2023
11 changes: 11 additions & 0 deletions exampleSite/content/homepage/internal.md
spi43984 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
title: "Link2InternalPage"
zjedi marked this conversation as resolved.
Show resolved Hide resolved
weight: 99
header_menu_title: "Contacts"
navigation_menu_title: "Contacts"
header_menu: true
internal: /contacts/
internal_hide: false
---
This file creates an internal link on the cover page without the leading icon.
If the parameter internal_hide is set to true neither this page will be shown nor the navigation menu entry (but the link will be).
If set to false, the link, navigation menu and the content will be rendered.
3 changes: 3 additions & 0 deletions layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{{ $sections := $headless.Resources.ByType "page" }}
{{ $sections := cond .Site.BuildDrafts $sections (where $sections "Draft" "==" false) }}
{{ $content := where $sections "Params.external" "==" nil }}
{{ $content := where $sections "Params.internal_hide" "ne" true }}

<!-- Welcome screen that scrolls out of view -->
{{ if not .Params.header_use_video }}
Expand Down Expand Up @@ -34,6 +35,8 @@

{{ if isset .Params "external" }}
<a class='btn site-menu' href='{{ .Params.external }}'>{{ $button_title }}&nbsp;<icon class="fa fa-external-link"></icon></a>
{{ else if isset .Params "internal" }}
<a class='btn site-menu' href='{{ .Params.internal }}'>{{ $button_title }}&nbsp;</a>
{{ else }}
{{ $fnav_title := .Title }}{{ with .Params.navigation_menu_title }}{{ $fnav_title = . }}{{ end }}
<a class='btn site-menu' data-title-anchor='{{ anchorize $fnav_title }}' href='#{{ anchorize $fnav_title }}'>{{ $button_title }}</a>
Expand Down