mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Refactor Org mode front matter: Introduce '#+KEY[]:' array notation
Hugo requires some front matter values to be arrays (e.g. for taxonomies). Org mode front matter syntax (`#+KEY: VALUE`) does however not support anything but string values normally - which is why goorgeous hardcoded the values for the keys tags, categories & aliases to be parsed as string arrays. This causes problems with custom taxonomies. A simple thing we can do instead is make keywords ending in '[]' be parsed as string arrays.
This commit is contained in:
parent
b6867bf806
commit
fad183c4ae
1 changed files with 4 additions and 1 deletions
|
@ -187,7 +187,10 @@ func (d Decoder) unmarshalORG(data []byte, v interface{}) error {
|
||||||
frontMatter := make(map[string]interface{}, len(document.BufferSettings))
|
frontMatter := make(map[string]interface{}, len(document.BufferSettings))
|
||||||
for k, v := range document.BufferSettings {
|
for k, v := range document.BufferSettings {
|
||||||
k = strings.ToLower(k)
|
k = strings.ToLower(k)
|
||||||
if k == "tags" || k == "categories" || k == "aliases" {
|
if strings.HasSuffix(k, "[]") {
|
||||||
|
frontMatter[k[:len(k)-2]] = strings.Fields(v)
|
||||||
|
} 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)
|
frontMatter[k] = strings.Fields(v)
|
||||||
} else {
|
} else {
|
||||||
frontMatter[k] = v
|
frontMatter[k] = v
|
||||||
|
|
Loading…
Reference in a new issue