Skip to content

Commit

Permalink
Merge pull request #38 from pthoelken/main
Browse files Browse the repository at this point in the history
adding function to open a link in new tab in social section
  • Loading branch information
LordMathis committed Apr 26, 2024
2 parents 5edc07c + d764a13 commit 80e1b7f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ key = 0
name = "github"
url = "https://github.com/gohugoio"
icon = "fa-brands fa-github" # Add link to your icon font to `layouts/partials/custom-head.html`
target = "_blank" # Defines your target option in a-href. _blank for a new Tab for example.
aria = "GitHub Profile" # Define the aria label for accessibility like page reader - this is better for your SEO

[[params.social]]
key = 1
Expand Down
5 changes: 5 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,23 @@ published = true # Show published data on post page
key = 0
name = "github"
url = "https://github.com/gohugoio"
target = "_blank"
aria = "GitHub Profile"

[[params.social]]
key = 1
name = "twitter"
url = "https://www.example.com"
aria = "Twitter Profile"

[[params.social]]
key = 2
name = "linkedin"
url = "https://www.example.com"
aria = "LinkedIn Profile"

[[params.social]]
key = 3
name = "email"
url = "mailto:email@example.com"
aria = "My e-Mail Address"
4 changes: 2 additions & 2 deletions layouts/partials/social.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
{{ range sort .Site.Params.social "key"}}
<li>
{{ if isset . "icon" }}
<a href="{{ .url | safeURL }}" aria-hidden="true" title="{{ .name }}" {{ if .rel }} rel="{{ .rel }}"{{ end }}>
<a href="{{ .url | safeURL }}" {{ if .target }} target="{{ .target }}" {{ end }} {{ if .aria }} aria-label="{{ .aria }}" {{ else }} aria-hidden="true" {{ end }} title="{{ .name }}" {{ if .rel }} rel="{{ .rel }}"{{ end }}>
<i class="{{ .icon }}"></i>
</a>
{{ else }}
<a href="{{ .url | safeURL }}" {{ if .rel }} rel="{{ .rel }}"{{ end }}>{{ .name }}</a>
<a href="{{ .url | safeURL }}" {{ if .target }} target="{{ .target }}" {{ if .aria }} aria-label="{{ .aria }}" {{ else }} aria-hidden="true" {{ end }} {{ end }} {{ if .rel }} rel="{{ .rel }}"{{ end }}>{{ .name }}</a>
{{ end }}
</li>
{{ end }}
Expand Down

0 comments on commit 80e1b7f

Please sign in to comment.