|
1 | 1 | {{- /* layouts/_default/_markup/render-link.html */ -}}
|
2 | 2 | <a href="{{ .Destination | safeURL }}"
|
3 |
| - {{- with .Title}} title="{{ . }}"{{ end -}} |
4 |
| - {{- $isExternal := strings.HasPrefix .Destination "http" -}} |
5 |
| - {{- if $isExternal }} target="_blank" rel="noopener"{{ end -}} |
6 |
| - {{- $class := "" -}} |
7 |
| - {{- if in .Destination "?class=" -}} |
8 |
| - {{- $class = index (findRE `class=([^&#]*)` .Destination) 0 | replace `class=` `` | replace `+` ` ` -}} |
9 |
| - class="{{ $class }}" |
10 |
| - {{- end -}} |
11 |
| - > |
12 |
| - {{- .Text | safeHTML -}} |
13 |
| - {{- if and $isExternal (not (in (string $class) "btn")) (not (in (string $class) "breadcrumb-link-parent")) (not (in (string $class) "social-link-container")) -}} |
14 |
| - {{- partial "icon.html" (dict "style" "solid" "name" "arrow-up-right-from-square" "class" "inline-block ml-[.5] pb-[.4]" "width" "1em" "height" "0.7em") -}} |
15 |
| - {{- end -}} |
16 |
| -</a> |
| 3 | + {{- with .Title}} title="{{ . }}"{{ end -}} |
| 4 | + {{- $isExternal := strings.HasPrefix .Destination "http" -}} |
| 5 | +{{- if $isExternal }} target="_blank" rel="noopener"{{ end -}} |
| 6 | +{{- $class := "" -}} |
| 7 | +{{- if in .Destination "?class=" -}} |
| 8 | +{{- $class = index (findRE `class=([^&#]*)` .Destination) 0 | replace `class=` `` | replace `+` ` ` -}} |
| 9 | +class="{{ $class }}" |
| 10 | +{{- end -}} |
| 11 | +> |
| 12 | +{{- .Text | safeHTML -}} |
| 13 | +{{- if and $isExternal (not (in (string $class) "btn")) (not (in (string $class) "breadcrumb-link-parent")) (not (in (string $class) "social-link-container")) -}} |
| 14 | +{{- partial "icon.html" (dict "style" "solid" "name" "arrow-up-right-from-square" "class" "inline-block ml-[.5] pb-[.4]" "width" "1em" "height" "0.7em") -}} |
| 15 | +{{- end -}} |
| 16 | +</a><!-- |
| 17 | +This empty Go template tag with hyphens is a Hugo trick. |
| 18 | +It consumes any trailing whitespace (like newlines) from this partial's output. |
| 19 | +This prevents the markdown renderer from adding an unwanted space after the <a> tag |
| 20 | +and before any subsequent punctuation (e.g., "link," vs. "link ,"). |
| 21 | +-->{{- "" -}} |
0 commit comments