Skip to content

Commit

Permalink
added alternative title to link block
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivia206 committed Oct 3, 2024
1 parent 1fc43ef commit 6d4353a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion layouts/partials/blocks/templates/links.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@
<li itemscope itemtype="https://schema.org/WebPage">
<div class="link-content">
{{ $title := partial "PrepareHTML" .title }}
{{ $alt_title := "" }}
{{ if .alt_title }}
{{ $alt_title = partial "PrepareHTML" .alt_title }}
{{ end }}

{{ $a11y_title := cond $alt_title $alt_title $title }}
{{ $url := .url }}
{{ $isExternal := .external | default true }}
{{ $link_title := cond $isExternal (safeHTML (i18n "commons.link.blank_aria" (dict "Title" $title))) $title}}
{{ $link_title := cond $isExternal (safeHTML (i18n "commons.link.blank_aria" (dict "Title" $a11y_title))) $a11y_title}}

<link itemprop="url" href="{{ .url }}">
<a itemprop="relatedLink" href="{{ .url }}" title="{{ $link_title }}" {{ if $isExternal -}} target="_blank" rel="noopener" {{- end }}>
Expand Down

0 comments on commit 6d4353a

Please sign in to comment.