Workaround for Jekyllr frontmatter

This commit is contained in:
Qiming Teng
2017-11-30 17:18:18 +08:00
parent edcb39d46c
commit b84ac59624
13 changed files with 11 additions and 15 deletions
+8 -1
View File
@@ -199,6 +199,10 @@ func walkConfigFiles(inDir string, fn func(name, path string, data [][]byte)) er
if err != nil {
return err
}
// workaround for Jekyllr limit
if bytes.HasPrefix(data, []byte("---\n")) {
return fmt.Errorf("YAML file cannot start with \"---\", please remove the first line")
}
name := strings.TrimSuffix(file, ext)
var docs [][]byte
@@ -217,7 +221,10 @@ func walkConfigFiles(inDir string, fn func(name, path string, data [][]byte)) er
if err != nil {
return fmt.Errorf("%s: %v", path, err)
}
docs = append(docs, out)
// deal with "empty" document (e.g. pure comments)
if string(out) != "null" {
docs = append(docs, out)
}
}
} else {
docs = append(docs, data)