Skip to content

Commit

Permalink
Separate the logic of outdated_translation vs lastmod
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Delmas <[email protected]>
  • Loading branch information
tdelmas committed Oct 1, 2023
1 parent dec7fe2 commit 4d0c325
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
2 changes: 2 additions & 0 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@
{{- if.Page.Params.show_lastmod -}}
{{- partial "lastmod" . -}}
{{- end -}}

{{- partial "outdated_translation" . -}}

{{- $scratch := newScratch -}}
{{- $lang := .Page.Language.Lang -}}
Expand Down
21 changes: 0 additions & 21 deletions layouts/partials/lastmod.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,4 @@

{{ if eq .Page.Section "docs" }} | <a href="{{ "docs" | relLangURL }}">{{ i18n "see_all_doc" }}</a>{{ end }}
</p>

{{ $curpage := .Page }}
{{ if and (ne $curpage.Language.Lang "en") (not .Page.Params.untranslated) }}
{{/* If we are not in English we search for the English version */}}
{{ range $curpage.Translations }}
{{ if eq "en" .Language.Lang }}
{{ if .Page.Lastmod }}
{{/* To compare the Lastmod with the current translation */}}
{{ if ne $curpage.Lastmod .Page.Lastmod }}
<p>
<i>
{{ i18n "old_version" }}
(<time datetime="{{ .Page.Lastmod.Format "2006-01-02" }}">{{ .Page.Lastmod | time.Format $.Site.Params.time_format_default }}</time>)
<a href="{{ .Page.RelPermalink }}">{{ i18n "view_in_english" }}</a>
</i>
</p>
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
<!--googleon: all-->
22 changes: 22 additions & 0 deletions layouts/partials/outdated_translation.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!--googleoff: all-->
{{ $curpage := .Page }}
{{ if and (ne $curpage.Language.Lang "en") (not .Page.Params.untranslated) }}
{{/* If we are not in English we search for the English version */}}
{{ range $curpage.Translations }}
{{ if eq "en" .Language.Lang }}
{{ if .Page.Lastmod }}
{{/* To compare the Lastmod with the current translation */}}
{{ if ne $curpage.Lastmod .Page.Lastmod }}
<p>
<i>
{{ i18n "old_version" }}
(<time datetime="{{ .Page.Lastmod.Format "2006-01-02" }}">{{ .Page.Lastmod | time.Format $.Site.Params.time_format_default }}</time>)
<a href="{{ .Page.RelPermalink }}">{{ i18n "view_in_english" }}</a>
</i>
</p>
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
<!--googleon: all-->

0 comments on commit 4d0c325

Please sign in to comment.