mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
metadecoders: Add support for native org dates in frontmatter
PR #7433 added support for Org timestamps for the DATE header. This PR widens the support with additional front matter headers LASTMOD, PUBLISHDATE and EXPIRYDATE. Fixes #8536
This commit is contained in:
parent
32ea40aa82
commit
bdbfacb868
2 changed files with 4 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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},
|
||||
|
|
Loading…
Reference in a new issue