|
42 | 42 | {{- with $buttons -}} |
43 | 43 | <div class="buttons"> |
44 | 44 | {{- range . -}} |
45 | | - {{- $href := .link -}} |
46 | | - {{- $label := .label -}} |
47 | | - |
48 | | - {{- if and $href (not (hasPrefix $href "http")) -}} |
49 | | - {{- with (site.GetPage $href) -}} |
50 | | - {{- $href = .RelPermalink -}} |
51 | | - {{- if not $label -}} |
52 | | - {{- $label = .LinkTitle -}} |
| 45 | + |
| 46 | + {{- $button_link := .link -}} |
| 47 | + {{- $button_label := .label -}} |
| 48 | + |
| 49 | + {{- with $button_link -}} |
| 50 | + {{- with site.GetPage . -}} |
| 51 | + {{- with .Params.redirect -}} |
| 52 | + {{- $button_link = . -}} |
| 53 | + {{- else -}} |
| 54 | + {{- $button_link = .RelPermalink -}} |
| 55 | + {{- end -}} |
| 56 | + {{- if not $button_label -}} |
| 57 | + {{- $button_label = .LinkTitle -}} |
53 | 58 | {{- end -}} |
54 | 59 | {{- end -}} |
55 | 60 | {{- end -}} |
56 | 61 |
|
57 | | - {{- if not $label -}} |
58 | | - {{- $label = i18n "explore" | default "Explore" -}} |
| 62 | + {{- $is_external := and (hasPrefix $button_link "http") (not (hasPrefix $button_link site.BaseURL)) -}} |
| 63 | + |
| 64 | + {{- if not $button_label -}} |
| 65 | + {{- $button_label = i18n "explore" | default "Explore" -}} |
59 | 66 | {{- end -}} |
60 | 67 |
|
61 | | - <a href="{{ $href }}" |
62 | | - title="{{ trim $label " " }}" |
| 68 | + <a href="{{ $button_link }}" |
63 | 69 | class="hero-button" |
64 | | - {{- with .style -}}style="{{ . | safeCSS }}"{{- end -}}> |
65 | | - {{ $label }} |
| 70 | + {{ with .style }}style="{{ . | safeCSS }}"{{ end }} |
| 71 | + {{ if $is_external }}target="_blank" rel="noopener noreferrer"{{ end }}> |
| 72 | + {{- $button_label -}} |
| 73 | + |
| 74 | + {{- if $is_external -}} |
| 75 | + {{- partialCached "utils/icon.html" "external" "external" -}} |
| 76 | + {{- end -}} |
66 | 77 | </a> |
| 78 | + |
67 | 79 | {{- end -}} |
68 | 80 | </div> |
69 | 81 | {{- end -}} |
|
72 | 84 | {{- if $hero -}} |
73 | 85 |
|
74 | 86 | {{- $hero_link := $hero.link -}} |
75 | | - {{- $hero_page := site.GetPage $hero_link -}} |
76 | | - {{- $is_external := not $hero_page -}} |
77 | | - {{- $hero_cover := . -}} |
78 | | - |
79 | | - {{- if $hero_page -}} |
80 | | - {{- $hero_link = $hero_page.RelPermalink -}} |
81 | | - {{- $hero_cover = $hero_page -}} |
82 | | - {{- end -}} |
83 | | - |
84 | 87 | {{- $hero_title := $hero.title -}} |
85 | | - {{- if and $hero_page (not $hero_title) -}} |
86 | | - {{- $hero_title = $hero_page.LinkTitle -}} |
| 88 | + {{- $hero_cover := $hero.cover -}} |
| 89 | + |
| 90 | + {{- with $hero_link -}} |
| 91 | + {{- with site.GetPage . -}} |
| 92 | + {{- with .Params.redirect -}} |
| 93 | + {{- $hero_link = . -}} |
| 94 | + {{- else -}} |
| 95 | + {{- $hero_link = .RelPermalink -}} |
| 96 | + {{- end -}} |
| 97 | + {{- if not $hero_title -}} |
| 98 | + {{- $hero_title = .LinkTitle -}} |
| 99 | + {{- end -}} |
| 100 | + {{- if not $hero_cover -}} |
| 101 | + {{- $hero_cover = . -}} |
| 102 | + {{- end -}} |
| 103 | + {{- end -}} |
87 | 104 | {{- end -}} |
88 | 105 |
|
89 | | - <a class="hero-column" |
90 | | - href="{{ $hero_link }}" |
91 | | - {{ if $is_external }}rel="noopener noreferrer"{{ end }}> |
| 106 | + {{- $is_external := and (hasPrefix $hero_link "http") (not (hasPrefix $hero_link site.BaseURL)) -}} |
| 107 | + |
| 108 | + {{- with $hero_link -}} |
| 109 | + <a class="hero-column" |
| 110 | + href="{{ . }}" |
| 111 | + {{ if $is_external }}target="_blank" rel="noopener noreferrer"{{ end }}> |
| 112 | + {{- end -}} |
92 | 113 |
|
| 114 | + {{- with $hero_title -}} |
93 | 115 | <h2 class="title" |
94 | 116 | {{ with .Params.hero.class }}class="{{ . }}"{{ end }} |
95 | 117 | {{ with .Params.hero.style }}style="{{ . | safeCSS }}"{{ end }}> |
96 | | - {{- $hero_title -}} |
| 118 | + {{- . -}} |
| 119 | + |
| 120 | + {{- if $is_external -}} |
| 121 | + {{- partialCached "utils/icon.html" "external" "external" -}} |
| 122 | + {{- end -}} |
97 | 123 | </h2> |
| 124 | + {{- end -}} |
| 125 | + |
| 126 | + {{- with $hero_cover -}} |
| 127 | + {{- partialCached "main/cover.html" . . -}} |
| 128 | + {{- end -}} |
98 | 129 |
|
99 | | - {{- partialCached "main/cover.html" $hero_cover $hero_cover -}} |
100 | | - </a> |
| 130 | + {{- with $hero_link -}}</a>{{- end -}} |
101 | 131 |
|
102 | 132 | {{- end -}} |
103 | 133 | </section> |
|
0 commit comments