export three functions
parent
8af33dec47
commit
e03fa7eb0c
|
@ -43,7 +43,7 @@ func PreProccessPUT(
|
||||||
|
|
||||||
switch kind {
|
switch kind {
|
||||||
case "frontmatter-only":
|
case "frontmatter-only":
|
||||||
if file, err = parseFrontMatterOnlyFile(data, i.Name()); err != nil {
|
if file, err = ParseFrontMatterOnlyFile(data, i.Name()); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case "content-only":
|
case "content-only":
|
||||||
|
@ -51,7 +51,7 @@ func PreProccessPUT(
|
||||||
mainContent = strings.TrimSpace(mainContent)
|
mainContent = strings.TrimSpace(mainContent)
|
||||||
file = []byte(mainContent)
|
file = []byte(mainContent)
|
||||||
case "complete":
|
case "complete":
|
||||||
if file, err = parseCompleteFile(data, i.Name(), u.FrontMatter); err != nil {
|
if file, err = ParseCompleteFile(data, i.Name(), u.FrontMatter); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -63,10 +63,10 @@ func PreProccessPUT(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseFrontMatterOnlyFile parses a frontmatter only file
|
// ParseFrontMatterOnlyFile parses a frontmatter only file
|
||||||
func parseFrontMatterOnlyFile(data interface{}, filename string) ([]byte, error) {
|
func ParseFrontMatterOnlyFile(data interface{}, filename string) ([]byte, error) {
|
||||||
frontmatter := strings.TrimPrefix(filepath.Ext(filename), ".")
|
frontmatter := strings.TrimPrefix(filepath.Ext(filename), ".")
|
||||||
f, err := parseFrontMatter(data, frontmatter)
|
f, err := ParseFrontMatter(data, frontmatter)
|
||||||
fString := string(f)
|
fString := string(f)
|
||||||
|
|
||||||
// If it's toml or yaml, strip frontmatter identifier
|
// If it's toml or yaml, strip frontmatter identifier
|
||||||
|
@ -84,8 +84,8 @@ func parseFrontMatterOnlyFile(data interface{}, filename string) ([]byte, error)
|
||||||
return f, err
|
return f, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseFrontMatter is the frontmatter parser
|
// ParseFrontMatter is the frontmatter parser
|
||||||
func parseFrontMatter(data interface{}, frontmatter string) ([]byte, error) {
|
func ParseFrontMatter(data interface{}, frontmatter string) ([]byte, error) {
|
||||||
var mark rune
|
var mark rune
|
||||||
|
|
||||||
switch frontmatter {
|
switch frontmatter {
|
||||||
|
@ -108,8 +108,8 @@ func parseFrontMatter(data interface{}, frontmatter string) ([]byte, error) {
|
||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseCompleteFile parses a complete file
|
// ParseCompleteFile parses a complete file
|
||||||
func parseCompleteFile(data map[string]interface{}, filename string, frontmatter string) ([]byte, error) {
|
func ParseCompleteFile(data map[string]interface{}, filename string, frontmatter string) ([]byte, error) {
|
||||||
mainContent := ""
|
mainContent := ""
|
||||||
|
|
||||||
if _, ok := data["content"]; ok {
|
if _, ok := data["content"]; ok {
|
||||||
|
@ -125,7 +125,7 @@ func parseCompleteFile(data map[string]interface{}, filename string, frontmatter
|
||||||
data["date"] = data["date"].(string) + ":00"
|
data["date"] = data["date"].(string) + ":00"
|
||||||
}
|
}
|
||||||
|
|
||||||
front, err := parseFrontMatter(data, frontmatter)
|
front, err := ParseFrontMatter(data, frontmatter)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(frontmatter)
|
fmt.Println(frontmatter)
|
||||||
|
|
Loading…
Reference in New Issue