git: f8c0dc03a7 - main - documentation/themes: Fix the Download PDF link after Hugo upgrade

"Danilo G. Baio" <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.doc
Message-ID <[email protected]>
The branch main has been updated by dbaio:

URL: https://cgit.FreeBSD.org/doc/commit/?id=f8c0dc03a753351c921c2b37d45526ab08d58b83

commit f8c0dc03a753351c921c2b37d45526ab08d58b83
Author:     Danilo G. Baio <[email protected]>
AuthorDate: 2024-06-29 13:57:59 +0000
Commit:     Danilo G. Baio <[email protected]>
CommitDate: 2024-06-29 13:57:59 +0000

    documentation/themes: Fix the Download PDF link after Hugo upgrade
    
    PR:             279896
    Reported by:    [email protected]
---
 documentation/themes/beastie/layouts/articles/list.html   | 9 ++++++---
 documentation/themes/beastie/layouts/articles/single.html | 9 ++++++---
 documentation/themes/beastie/layouts/books/list.html      | 9 ++++++---
 documentation/themes/beastie/layouts/books/single.html    | 9 ++++++---
 4 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/documentation/themes/beastie/layouts/articles/list.html b/documentation/themes/beastie/layouts/articles/list.html
index deecb60507..14120e6b90 100644
--- a/documentation/themes/beastie/layouts/articles/list.html
+++ b/documentation/themes/beastie/layouts/articles/list.html
@@ -42,9 +42,12 @@
       <div class="resources">
         <h3>{{ i18n "resources" }}</h3>
         <ul class="contents">
-          {{ $pathSections := split .Page.File "/" }}
-          {{ $path := printf "%s/%s/%s_%s.pdf" (index $pathSections 0) (index $pathSections 1) (index $pathSections 1) $.Site.Home.Language }}
-          {{ $pdfUrl := printf "%s%s/%s" $.Site.Params.downloadBaseUrl $.Site.Home.Language $path }}
+          {{ $pathSections := split .Page.Path "/" }}
+          {{ $docLang := $.Site.Home.Language.Lang }}
+          {{ $docType := index $pathSections 1 }}
+          {{ $docName := index $pathSections 2 }}
+          {{ $pdfFilename := printf "%s_%s.pdf" $docName $docLang }}
+          {{ $pdfUrl := printf "%s%s/%s/%s/%s" $.Site.Params.downloadBaseUrl $docLang $docType $docName $pdfFilename }}
           <li><i class="fa fa-file-pdf-o" aria-hidden="true" title="{{ i18n "download-pdf" }}"></i><a href="{{ $pdfUrl }}">{{ i18n "download-pdf" }}</a></li>
           {{ $editUrl := printf "%s%s/%s" $.Site.Params.editBaseUrl $.Site.Home.Language .Page.File }}
           <li><i class="fa fa-pencil-square-o" aria-hidden="true" title="{{ i18n "edit-page" }}"></i><a href="{{ $editUrl }}" target="_blank">{{ i18n "edit-page" }}</a></li>
diff --git a/documentation/themes/beastie/layouts/articles/single.html b/documentation/themes/beastie/layouts/articles/single.html
index deecb60507..14120e6b90 100644
--- a/documentation/themes/beastie/layouts/articles/single.html
+++ b/documentation/themes/beastie/layouts/articles/single.html
@@ -42,9 +42,12 @@
       <div class="resources">
         <h3>{{ i18n "resources" }}</h3>
         <ul class="contents">
-          {{ $pathSections := split .Page.File "/" }}
-          {{ $path := printf "%s/%s/%s_%s.pdf" (index $pathSections 0) (index $pathSections 1) (index $pathSections 1) $.Site.Home.Language }}
-          {{ $pdfUrl := printf "%s%s/%s" $.Site.Params.downloadBaseUrl $.Site.Home.Language $path }}
+          {{ $pathSections := split .Page.Path "/" }}
+          {{ $docLang := $.Site.Home.Language.Lang }}
+          {{ $docType := index $pathSections 1 }}
+          {{ $docName := index $pathSections 2 }}
+          {{ $pdfFilename := printf "%s_%s.pdf" $docName $docLang }}
+          {{ $pdfUrl := printf "%s%s/%s/%s/%s" $.Site.Params.downloadBaseUrl $docLang $docType $docName $pdfFilename }}
           <li><i class="fa fa-file-pdf-o" aria-hidden="true" title="{{ i18n "download-pdf" }}"></i><a href="{{ $pdfUrl }}">{{ i18n "download-pdf" }}</a></li>
           {{ $editUrl := printf "%s%s/%s" $.Site.Params.editBaseUrl $.Site.Home.Language .Page.File }}
           <li><i class="fa fa-pencil-square-o" aria-hidden="true" title="{{ i18n "edit-page" }}"></i><a href="{{ $editUrl }}" target="_blank">{{ i18n "edit-page" }}</a></li>
diff --git a/documentation/themes/beastie/layouts/books/list.html b/documentation/themes/beastie/layouts/books/list.html
index 2668a3de8a..08672d3097 100644
--- a/documentation/themes/beastie/layouts/books/list.html
+++ b/documentation/themes/beastie/layouts/books/list.html
@@ -129,9 +129,12 @@
       <div class="resources">
         <h3>{{ i18n "resources" }}</h3>
         <ul class="contents">
-          {{ $pathSections := split .Page.File "/" }}
-          {{ $path := printf "%s/%s/%s_%s.pdf" (index $pathSections 0) (index $pathSections 1) (index $pathSections 1) $.Site.Home.Language }}
-          {{ $pdfUrl := printf "%s%s/%s" $.Site.Params.downloadBaseUrl $.Site.Home.Language $path }}
+          {{ $pathSections := split .Page.Path "/" }}
+          {{ $docLang := $.Site.Home.Language.Lang }}
+          {{ $docType := index $pathSections 1 }}
+          {{ $docName := index $pathSections 2 }}
+          {{ $pdfFilename := printf "%s_%s.pdf" $docName $docLang }}
+          {{ $pdfUrl := printf "%s%s/%s/%s/%s" $.Site.Params.downloadBaseUrl $docLang $docType $docName $pdfFilename }}
           <li><i class="fa fa-file-pdf-o" aria-hidden="true" title="{{ i18n "download-pdf" }}"></i><a href="{{ $pdfUrl }}">{{ i18n "download-pdf" }}</a></li>
           {{ $editUrl := printf "%s%s/%s" $.Site.Params.editBaseUrl $.Site.Home.Language .Page.File }}
           <li><i class="fa fa-pencil-square-o" aria-hidden="true" title="{{ i18n "edit-page" }}"></i><a href="{{ $editUrl }}" target="_blank">{{ i18n "edit-page" }}</a></li>
diff --git a/documentation/themes/beastie/layouts/books/single.html b/documentation/themes/beastie/layouts/books/single.html
index 2668a3de8a..08672d3097 100644
--- a/documentation/themes/beastie/layouts/books/single.html
+++ b/documentation/themes/beastie/layouts/books/single.html
@@ -129,9 +129,12 @@
       <div class="resources">
         <h3>{{ i18n "resources" }}</h3>
         <ul class="contents">
-          {{ $pathSections := split .Page.File "/" }}
-          {{ $path := printf "%s/%s/%s_%s.pdf" (index $pathSections 0) (index $pathSections 1) (index $pathSections 1) $.Site.Home.Language }}
-          {{ $pdfUrl := printf "%s%s/%s" $.Site.Params.downloadBaseUrl $.Site.Home.Language $path }}
+          {{ $pathSections := split .Page.Path "/" }}
+          {{ $docLang := $.Site.Home.Language.Lang }}
+          {{ $docType := index $pathSections 1 }}
+          {{ $docName := index $pathSections 2 }}
+          {{ $pdfFilename := printf "%s_%s.pdf" $docName $docLang }}
+          {{ $pdfUrl := printf "%s%s/%s/%s/%s" $.Site.Params.downloadBaseUrl $docLang $docType $docName $pdfFilename }}
           <li><i class="fa fa-file-pdf-o" aria-hidden="true" title="{{ i18n "download-pdf" }}"></i><a href="{{ $pdfUrl }}">{{ i18n "download-pdf" }}</a></li>
           {{ $editUrl := printf "%s%s/%s" $.Site.Params.editBaseUrl $.Site.Home.Language .Page.File }}
           <li><i class="fa fa-pencil-square-o" aria-hidden="true" title="{{ i18n "edit-page" }}"></i><a href="{{ $editUrl }}" target="_blank">{{ i18n "edit-page" }}</a></li>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.