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

Adds an external link icon beside links that take the user off-site #54

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions assets/scss/_header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,25 @@
}
&:hover {
color: var(--menu-link-color-hover);

&.external-link:after, &.child-external-link span.menu-item__name:after {
filter: invert(35%) sepia(54%) saturate(0%) hue-rotate(152deg) brightness(91%) contrast(75%);
}
}
}

.external-link:after, .child-external-link span.menu-item__name:after {
content: '';
display: inline-block;
vertical-align: middle;
height: 10px;
width: 10px;
margin-left: 6px;
margin-bottom: 3px;
background-image: url("data:image/svg+xml,%3Csvg width='10' height='10' viewBox='0 0 10 10' fill='transparent' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m1 8.778 6.667-6.666M1 1h8v8' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
transition: filter 0.5s ease;
@media (prefers-reduced-motion: reduce) {
transition: none;
}
}

Expand Down
38 changes: 10 additions & 28 deletions exampleSite/config/_default/languages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ en:
name: "Example Child Page"
url: "/example-page/"
weight: 1
post: "Lorem ipsum dolor sit amet consectetuer adipiscing elit aenean commodo."
post: "Nulla consequat massa quis enim. Donec pede justo."
parent: "about"
- identifier: "child-2"
name: "Example Child Page"
Expand All @@ -39,44 +39,26 @@ en:
post: "Aenean commodo ligula get dolor. Aenean massa."
parent: "about"
- identifier: "child-3"
name: "Example Child Page"
url: "/example-page/"
name: "Example External page"
url: "https://cncf.io?ref=dot-org"
weight: 3
post: "Nulla consequat massa quis enim. Donec pede justo."
parent: "about"
- identifier: "example"
name: "Example"
url: "/example-page/"
weight: 2
- identifier: "example-1"
name: "Example Child Page"
url: "/example-page/"
weight: 1
post: "Lorem ipsum dolor sit amet consectetuer adipiscing elit aenean commodo."
parent: "example"
- identifier: "example-2"
name: "Example Child Page"
url: "/example-page/"
weight: 2
post: "Nulla consequat massa quis enim. Donec pede justo."
parent: "example"
- identifier: "example-3"
name: "Example Child Page"
url: "/example-page/"
weight: 3
post: "Aenean commodo ligula get dolor. Aenean massa. "
parent: "example"
parent: "about"
- identifier: "demo-page"
name: "Demo Page"
url: "/demo-page/"
weight: 3
weight: 2
- identifier: "faq"
name: "FAQs"
url: "/faq/"
weight: 4
weight: 3
- identifier: "blog"
name: "Blog"
url: "/blog/"
weight: 4
- identifier: "example"
name: "External"
url: "https://cncf.io?ref=dot-org"
weight: 5
es:
languageName: Spanish
Expand Down
10 changes: 7 additions & 3 deletions layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@
<ul class="main-menu__wrapper">
{{ range . }}
<li class="top-menu-item{{ if .HasChildren }} menu-item-has-children{{ end }}">
<a href="{{ if .HasChildren }}#{{ else }}{{ .URL | relLangURL }}{{ end }}" class="menu-link">{{
.Name }}</a>
<a href="{{ if .HasChildren }}#{{ else }}{{ .URL | relLangURL }}{{ end }}"
class="menu-link{{ if strings.HasPrefix .URL "http" }} external-link{{ end }}">
{{ .Name }}
</a>
{{ if .HasChildren }}
<div class="sub-menu">
<ul class="sub-menu__nav">
{{ range .Children }}
<li class="menu-item">
<a href="{{ .URL | relLangURL }}" class="menu-link">{{ .Name }}
<a href="{{ .URL | relLangURL }}"
class="menu-link{{ if strings.HasPrefix .URL "http" }} child-external-link{{ end }}">
<span class="menu-item__name">{{ .Name }}</span>
{{ if .Post }}
<span class="menu-item__description">{{ .Post }}</span>
{{ end }}
Expand Down