1bl4z3r / hermit-V2

Continuing Hermit's legacy to be minimal and fast theme
https://1bl4z3r.github.io/hermit-V2/
MIT License
101 stars 45 forks source link

[BUG] - .WordCount Wissing When i18n Present in Single Page Posts #88

Closed paisleyrob closed 1 month ago

paisleyrob commented 1 month ago

Describe the bug {{ .WordCount }} Is missing on single page posts when there is i18n present.

To Reproduce Produce a single post and include i18n configuration. Note the metadata about the post includes the internationalization of wordCount but not the actual word count.

Expected behavior I expected the word count to be present regardless of the internationalization

I think the fix is the following:

--- themes/hermit-v2/layouts/partials/posts_single_info.html    2024-09-30 14:15:53.964528739 -0400
+++ layouts/partials/posts_single_info.html     2024-09-30 18:32:57.965923449 -0400
@@ -9,7 +9,7 @@
 {{- with .Params.categories }}
 <p>{{- partial "svg.html" (dict "context" . "name" "posts_single_categories") -}}{{- range . -}}<span class="category"><a href="{{ "categories/" | absLangURL }}{{ . | urlize }}">{{.}}</a></span>{{- end }}</p>
 {{- end }}
-<p>{{- partial "svg.html" (dict "context" . "name" "posts_single_wordcount") }}{{- if fileExists "i18n" -}} {{ i18n "wordCount" . -}} {{- else -}} {{ .WordCount }} Words {{- end -}} {{- partial "readTime.html" . -}}</p>
+<p>{{- partial "svg.html" (dict "context" . "name" "posts_single_wordcount") }}{{- if fileExists "i18n" -}} {{ i18n "wordCount" . -}} {{ .WordCount }} {{- else -}} {{ .WordCount }} Words {{- end -}} {{- partial "readTime.html" . -}}</p>
 <p>{{- partial "svg.html" (dict "context" . "name" "posts_single_date") }}{{ dateFormat .Site.Params.dateformNumTime .Date.Local -}}
     {{- if and (not (eq .Page.Params.ShowLastmod nil)) (.Page.Params.ShowLastmod) -}}
     {{- if and .GitInfo .Site.Params.gitUrl -}}
@@ -20,4 +20,4 @@
         {{ errorf "Lastmod is not found in Page Frontmatter or Lastmod is same as Date" }}
     {{- end -}}
     {{- end -}}
1bl4z3r commented 1 month ago

Hi @paisleyrob,

I think you are quite wrong here.

if i18n directory is not present (for English language only), control would be in {{ .WordCount }} Words part in else block.

However, I am open to suggestions.

PS. I am looking through your PR; and I think I might have to close that.

paisleyrob commented 1 month ago

@1bl4z3r I've updated the Pull Request associated with this issue to move the .WordCount outside of the internationalization.