Skip to content

Commit 8c29212

Browse files
committed
Refactor community translations component and enhance PDF resource handling in guide translations
1 parent 681f965 commit 8c29212

File tree

4 files changed

+48
-225
lines changed

4 files changed

+48
-225
lines changed

module/layouts/_partials/components/translations/community-translations.html

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

module/layouts/_partials/components/translations/community-translations2.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ <h6 class="card-title mb-2">
146146
</div>
147147

148148
<!-- Desktop Row -->
149-
<div class="row d-none d-md-flex align-items-center py-3 border-bottom">
149+
<div class="row d-none d-md-flex align-items-center py-3 border-bottom" {{ if eq hugo.Environment "development" -}}title="ReadOnline:={{ .ReadOnline }} | ReadPDF:={{ .ReadPDF }}"{{- end -}}>
150150
<div class="col-md-4">
151151
{{ .LanguageName }}
152152
{{- if .Date }}

module/layouts/_partials/functions/get-guide-translations-for-version.html

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
{{ $parts := split $pdfName "." }}
5454
{{ if ge (len $parts) 3 }}
5555
{{ $langFromPDF := index $parts (sub (len $parts) 2) }}
56-
{{ $pdfsByLang = merge $pdfsByLang (dict $langFromPDF .) }}
56+
{{ $pdfsByLang = merge $pdfsByLang (dict (lower $langFromPDF) .) }}
5757
{{ end }}
5858
{{ end }}
5959

@@ -70,7 +70,18 @@
7070
{{ end }}
7171
{{ end }}
7272
{{ $page := index $translationsByLang $lang }}
73-
{{ $pdfResource := index $pdfsByLang $lang }}
73+
74+
// Look up PDF by normalized lang
75+
{{ $langKey := lower $lang }}
76+
{{ $pdfResource := index $pdfsByLang $langKey }}
77+
78+
// Fallback: check the translation page’s own resources
79+
{{ if (and (not $pdfResource) $page) }}
80+
{{ $pagePdfResources := $page.Resources.Match $pdfPattern }}
81+
{{ if gt (len $pagePdfResources) 0 }}
82+
{{ $pdfResource = index $pagePdfResources 0 }}
83+
{{ end }}
84+
{{ end }}
7485

7586
{{/* Check if content is available for reading online */}}
7687
{{ $hasContent := false }}

site/hugo.yaml

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,41 @@ rss:
7474
description: "Subscribe to our RSS feed"
7575

7676
outputs:
77-
home: [html, json, rss]
78-
section: [html, rss]
79-
taxonomy: [html, rss]
80-
term: [html, rss]
81-
page: [html, rss]
77+
home:
78+
- html
79+
- json
80+
- rss
81+
- languages
82+
- translations
83+
section:
84+
- html
85+
- rss
86+
- guide-translations
87+
taxonomy:
88+
- html
89+
- rss
90+
term:
91+
- html
92+
- rss
93+
page:
94+
- html
95+
- rss
8296

8397
outputFormats:
8498
json:
85-
mediaType: "application/json"
86-
baseName: "pages"
99+
mediaType: application/json
100+
baseName: pages
101+
translations:
102+
mediaType: application/json
103+
baseName: translations
104+
languages:
105+
mediaType: application/json
106+
baseName: languages
107+
isPlainText: true
108+
guide-translations:
109+
mediaType: application/json
110+
baseName: guide-translations
111+
isPlainText: true
87112

88113
module:
89114
imports:
@@ -95,6 +120,8 @@ module:
95120
mounts:
96121
- source: content
97122
target: content
123+
- source: i18n
124+
target: i18n
98125
- path: github.com/nkdAgility/HugoGuides/module
99126
replacements:
100127
- github.com/nkdAgility/HugoGuides/module -> ../../module

0 commit comments

Comments
 (0)