adityatelange / adityatelange/hugo-PaperMod

[Bug]: Improper post date format in some cases

Aperta
#1,865 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
HTML
Stelle
13.9k
Fork
3.4k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

### What happened?

Raw (unformatted) `.Date` is used here:
https://github.com/adityatelange/hugo-PaperMod/blob/154d006e0182dfc7da38008323976b02e6bfab4a/layouts/_partials/post_meta.html#L4
... which leads to duplicate timezone information. Reasons are described here: https://github.com/gohugoio/hugo/issues/5907, https://github.com/gohugoio/hugo/issues/9096

This issue could be fixed by using explicit formatting like this:

```diff
diff --git a/layouts/_partials/post_meta.html b/layouts/_partials/post_meta.html
index c7c2635..decaef3 100644
--- a/layouts/_partials/post_meta.html
+++ b/layouts/_partials/post_meta.html
@@ -1,7 +1,7 @@
{{- $scratch := newScratch }}

{{- if not .Date.IsZero -}}
- {{- $scratch.Add "meta" (slice (printf "%s" (.Date) (.Date | time.Format (default ":date_long" site.Params.DateFormat)))) }}
+ {{- $scratch.Add "meta" (slice (printf "%s" (.Date | time.Format "2006-01-02T15:04:05-07:00") (.Date | time.Format (default ":date_long" site.Params.DateFormat)))) }}
{{- end }}

{{- if (.Param "ShowReadingTime") -}}
```

Another file worth checking:
https://github.com/adityatelange/hugo-PaperMod/blob/154d006e0182dfc7da38008323976b02e6bfab4a/layouts/_partials/templates/schema_json.html#L93-L94

### Steps to reproduce

1. Create post with date in timezone that doesn't match system timezone
2. Publish it
3. Check the date format in the post meta

### Hugo Version

Hugo >= 0.146.0 (Recommended - Minimum version required for PaperMod)

### PaperMod Version

154d006e0182dfc7da38008323976b02e6bfab4a

### What kind of devices are you seeing the problem on?

Desktop

### What browsers are you seeing the problem on?

_No response_

### Browser Version

_No response_

### Relevant log output

```shell

```

### Repository/Source Code link where this issue can be reproduced

_No response_

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.