Skip to content

Commit eb091e7

Browse files
refactor: Replace "ico" partial with "logo" partial (#140)
The icon usage was replaced by fontsource in #96. The remaining icon infrastructure was only used for the logos of operators. This PR simplifies the code by replacing the "ico" partial with a "logo" partial. In addition to the high complexity of the old "_ico.html", it had some issues: - Multiple return statements were used in one partial. This is not allowed as per docs ("Only one return statement is allowed per partial file."): https://gohugo.io/templates/partial/#example-getimage - The whole build process broke when an operator was added without related logo. --------- Signed-off-by: lennartrommeiss <lennart.rommeiss@deutschebahn.com> Co-authored-by: Lennart Rommeiss <61516567+lenderom@users.noreply.github.com> Co-authored-by: lennartrommeiss <lennart.rommeiss@deutschebahn.com>
1 parent d11c23d commit eb091e7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+13
-117
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

assets/sass/styles.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ img {
113113
.o-list__link {
114114
display: flex;
115115
align-items: center;
116+
margin-bottom: 1rem;
116117
}
117118

118119

layouts/operator/single.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
<div class="col-12 col-lg-4 sidemenu">
66
{{ partial "sidemenu.html" . }}
77
</div>
8-
98
<div class="col-12 col-lg-8" data-pagefind-body>
109
<div class="o-single__container content_with_heading">
1110
<div class="o-single__header">
1211
<div class="o-single__header__title">
1312
{{ $object := replace .Path (printf "/%s/" .Page.Type) "" }}
14-
{{ $logo := resources.Get (printf "svg/logos/%s.svg" $object) }}
15-
<img data-pagefind-meta="img" src="{{ $logo.RelPermalink }}" alt="" />
13+
{{ $logo := resources.Get (printf "images/logos/%s.svg" $object) }}
14+
{{ if $logo }}
15+
<img data-pagefind-meta="img" src="{{ $logo.RelPermalink }}" alt="" />
16+
{{ end }}
1617
<h1 data-pagefind-meta="title">{{ .Title }}</h1>
1718
</div>
1819
{{ partial "updateDate.html" . }}
1920
</div>
20-
2121
<div class="content" data-pagefind-weight="2.5">
2222
{{- with .Content -}}
2323
{{ . | replaceRE "(<h[2] id=\"([^\"]+)\".+)(</h[2]+>)" (print `<span class="a-anchorlink">${1}${3}<a href="#${2}" class="a-anchorlink__link" title="` (T "copyAnchorLink") `">` (partial "icon" "link") `</a></span>`) | safeHTML }}

layouts/partials/_ico.html

Lines changed: 0 additions & 50 deletions
This file was deleted.

layouts/partials/ico.html

Lines changed: 0 additions & 1 deletion
This file was deleted.

layouts/partials/logo.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{{ $logo := resources.Get (printf "/images/logos/%s.svg" .) }}
2+
{{ if $logo }}
3+
<img data-pagefind-meta="img" src="{{ $logo.RelPermalink }}" alt="" style="height: 1.3em; width: auto" />
4+
{{ end }}

layouts/partials/operator-list-item.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<a href="{{ .RelPermalink }}" class="o-list__link">
22
<div class="o-list__picture o-list__picture--operator">
33
{{ $object := replace .Path (printf "/%s/" .Page.Type) "" }}
4-
5-
{{ partial "ico" (dict "icon" $object "theme" "logos" "size" "50") }}
4+
{{ partial "logo" $object }}
65
</div>
76
<div>
87
{{ .Title }}

layouts/partials/sidemenu.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ <h3 id="related">{{ T "_operator__list_title"}}</h3>
3030
{{ $object := replace .Path (printf "/%s/" .Page.Type) "" }}
3131
<li>
3232
<a id="{{ .LinkTitle }}" href="{{ .RelPermalink }}">
33-
{{ partial "ico" (dict "icon" $object "theme" "logos" "height" "25" "width" "35") }}
33+
{{ partial "logo" $object }}
3434
{{ .LinkTitle }}
3535
</a>
3636
</li>
@@ -50,8 +50,8 @@ <h3 id="related">{{ T "_operator__nearby"}}</h3>
5050
{{ $object := replace .Path (printf "/%s/" .Page.Type) "" }}
5151
<li>
5252
<a id="{{ .LinkTitle }}" href="{{ .RelPermalink }}">
53-
{{ partial "ico" (dict "icon" $object "theme" "logos" "height" "25" "width" "35") }}
54-
{{ .LinkTitle }}
53+
{{ partial "logo" $object }}
54+
<span>{{ .LinkTitle }}</span>
5555
</a>
5656
</li>
5757
{{ end }}

layouts/shortcodes/ico.html

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)