mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
8915343075
commit
46f618756f
3 changed files with 4 additions and 4 deletions
|
@ -31,7 +31,7 @@ JSON
|
||||||
|
|
||||||
ORG
|
ORG
|
||||||
: a group of Org mode keywords in the format '`#+KEY: VALUE`'. Any line that does not start with `#+` ends the front matter section.
|
: a group of Org mode keywords in the format '`#+KEY: VALUE`'. Any line that does not start with `#+` ends the front matter section.
|
||||||
Keyword values can be either strings (`#+KEY: VALUE`) or a whitespace separated list of strings (`#+KEY[]: VALUE_1 VALUE_2`).
|
Array values can either be separated into multiple lines (`#+KEY: VALUE_1` and `#+KEY: VALUE_2`) or a whitespace separated list of strings (`#+KEY[]: VALUE_1 VALUE_2`).
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
|
|
|
@ -249,9 +249,8 @@ func (d Decoder) unmarshalORG(data []byte, v any) error {
|
||||||
k = strings.ToLower(k)
|
k = strings.ToLower(k)
|
||||||
if strings.HasSuffix(k, "[]") {
|
if strings.HasSuffix(k, "[]") {
|
||||||
frontMatter[k[:len(k)-2]] = strings.Fields(v)
|
frontMatter[k[:len(k)-2]] = strings.Fields(v)
|
||||||
} else if k == "tags" || k == "categories" || k == "aliases" {
|
} else if strings.Contains(v, "\n") {
|
||||||
log.Printf("warn: Please use '#+%s[]:' notation, automatic conversion is deprecated.", k)
|
frontMatter[k] = strings.Split(v, "\n")
|
||||||
frontMatter[k] = strings.Fields(v)
|
|
||||||
} else if k == "date" || k == "lastmod" || k == "publishdate" || k == "expirydate" {
|
} else if k == "date" || k == "lastmod" || k == "publishdate" || k == "expirydate" {
|
||||||
frontMatter[k] = parseORGDate(v)
|
frontMatter[k] = parseORGDate(v)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -125,6 +125,7 @@ func TestUnmarshalToInterface(t *testing.T) {
|
||||||
{[]byte(``), JSON, map[string]any{}},
|
{[]byte(``), JSON, map[string]any{}},
|
||||||
{[]byte(nil), JSON, map[string]any{}},
|
{[]byte(nil), JSON, map[string]any{}},
|
||||||
{[]byte(`#+a: b`), ORG, expect},
|
{[]byte(`#+a: b`), ORG, expect},
|
||||||
|
{[]byte("#+a: foo bar\n#+a: baz"), ORG, map[string]any{"a": []string{string("foo bar"), string("baz")}}},
|
||||||
{[]byte(`#+DATE: <2020-06-26 Fri>`), ORG, map[string]any{"date": "2020-06-26"}},
|
{[]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(`#+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(`#+PUBLISHDATE: <2020-06-26 Fri>`), ORG, map[string]any{"publishdate": "2020-06-26"}},
|
||||||
|
|
Loading…
Reference in a new issue