mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-22 20:02:11 +00:00
adding a front matter format to lead rune method
This commit is contained in:
parent
fb7d45e613
commit
6d9a2d2497
1 changed files with 15 additions and 0 deletions
|
@ -17,6 +17,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/BurntSushi/toml"
|
"github.com/BurntSushi/toml"
|
||||||
"launchpad.net/goyaml"
|
"launchpad.net/goyaml"
|
||||||
|
@ -86,6 +87,20 @@ func InterfaceToFrontMatter(in interface{}, mark rune) ([]byte, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FormatToLeadRune(kind string) rune {
|
||||||
|
switch strings.ToLower(kind) {
|
||||||
|
case "yaml":
|
||||||
|
return rune([]byte(YAML_LEAD)[0])
|
||||||
|
case "toml":
|
||||||
|
return rune([]byte(TOML_LEAD)[0])
|
||||||
|
case "json":
|
||||||
|
return rune([]byte(JSON_LEAD)[0])
|
||||||
|
default:
|
||||||
|
return rune([]byte(TOML_LEAD)[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func DetectFrontMatter(mark rune) (f *FrontmatterType) {
|
func DetectFrontMatter(mark rune) (f *FrontmatterType) {
|
||||||
switch mark {
|
switch mark {
|
||||||
case '-':
|
case '-':
|
||||||
|
|
Loading…
Reference in a new issue