Repository: gohugoio/hugo (language: go)

Issue:
Support for lastmod in Org Mode timestamp formats
I am using hugo v0.83.1+extended linux/amd64 BuildDate=unknown

Org Mode uses a timestamp format that is only partially 

In [issue 7433](https://github.com/gohugoio/hugo/pull/7433), Hugo was modified so that it could parse Org timestamps in the `.Date` variable. 

This does not seem to work when using the `lastmod` variable. 

Example:

`#+lastmod: 2021-05-15`

Renders as expected.

`#+lastmod: <2021-05-15 Sat>` or `#+lastmod: [2021-05-15 Sat]` does not render as the `.Lastmod` parameter defaults to the `.Date` variable.

Would it be possible to have Hugo recognise Org Mode timestamps for all [frontmatter date formats](https://gohugo.io/getting-started/configuration/#configure-front-matter)?




Discussion / hints:
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a **bug** and you can still reproduce this error on the <code>master</code> branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a **feature request**, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.
Sorry for the late response, yes, we should fix this. I suggest adding `lastmod`, `publishdate` and `expirydate` to that list.
Thanks!

My workaround is to use plain text (`2029-05-16`), but using Org mode (`[2029-05-16]`) dates is neater because it offers other Emacs functionality.

Fix patch:
diff --git a/parser/metadecoders/decoder.go b/parser/metadecoders/decoder.go
index 3f322ad92e4..a65731ae4ca 100644
--- a/parser/metadecoders/decoder.go
+++ b/parser/metadecoders/decoder.go
@@ -244,7 +244,7 @@ func (d Decoder) unmarshalORG(data []byte, v any) error {
 		} else if k == "tags" || k == "categories" || k == "aliases" {
 			jww.WARN.Printf("Please use '#+%s[]:' notation, automatic conversion is deprecated.", k)
 			frontMatter[k] = strings.Fields(v)
-		} else if k == "date" {
+		} else if k == "date" || k == "lastmod" || k == "publishdate" || k == "expirydate" {
 			frontMatter[k] = parseORGDate(v)
 		} else {
 			frontMatter[k] = v


Test patch:
diff --git a/parser/metadecoders/decoder_test.go b/parser/metadecoders/decoder_test.go
index 590c9fa9e0d..ff6f8c226a0 100644
--- a/parser/metadecoders/decoder_test.go
+++ b/parser/metadecoders/decoder_test.go
@@ -126,6 +126,9 @@ func TestUnmarshalToInterface(t *testing.T) {
 		{[]byte(nil), JSON, map[string]any{}},
 		{[]byte(`#+a: b`), ORG, expect},
 		{[]byte(`#+DATE: <2020-06-26 Fri>`), ORG, map[string]any{"date": "2020-06-26"}},
+		{[]byte(`#+LASTMOD: <2020-06-26 Fri>`), ORG, map[string]any{"lastmod": "2020-06-26"}},
+		{[]byte(`#+PUBLISHDATE: <2020-06-26 Fri>`), ORG, map[string]any{"publishdate": "2020-06-26"}},
+		{[]byte(`#+EXPIRYDATE: <2020-06-26 Fri>`), ORG, map[string]any{"expirydate": "2020-06-26"}},
 		{[]byte(`a = "b"`), TOML, expect},
 		{[]byte(`a: "b"`), YAML, expect},
 		{[]byte(`<root><a>b</a></root>`), XML, expect},