blogposts: finish up
This commit is contained in:
parent
48df8ace6e
commit
e8b8166ae9
@ -40,15 +40,16 @@ func newPost(postFile io.Reader) (Post, error) {
|
|||||||
return strings.TrimPrefix(scanner.Text(), tagName)
|
return strings.TrimPrefix(scanner.Text(), tagName)
|
||||||
}
|
}
|
||||||
|
|
||||||
title := readMetaLine(titleLine)
|
post := Post{
|
||||||
description := readMetaLine(descriptionLine)
|
Title: readMetaLine(titleLine),
|
||||||
tagsOneLine := readMetaLine(tagsLine)
|
Description: readMetaLine(descriptionLine),
|
||||||
|
Tags: strings.Split(readMetaLine(tagsLine), tagSeparator),
|
||||||
tags := strings.Split(tagsOneLine, ",")
|
Body: readBody(scanner),
|
||||||
for i, tag := range tags {
|
}
|
||||||
tags[i] = strings.TrimSpace(tag)
|
return post, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func readBody(scanner *bufio.Scanner) string {
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
if strings.TrimSpace(scanner.Text()) == bodySeparator {
|
if strings.TrimSpace(scanner.Text()) == bodySeparator {
|
||||||
break
|
break
|
||||||
@ -61,13 +62,5 @@ func newPost(postFile io.Reader) (Post, error) {
|
|||||||
buf.Write(scanner.Bytes())
|
buf.Write(scanner.Bytes())
|
||||||
buf.Write([]byte{'\n'})
|
buf.Write([]byte{'\n'})
|
||||||
}
|
}
|
||||||
body := strings.TrimSuffix(buf.String(), "\n")
|
return strings.TrimSuffix(buf.String(), "\n")
|
||||||
|
|
||||||
post := Post{
|
|
||||||
Title: title,
|
|
||||||
Description: description,
|
|
||||||
Tags: tags,
|
|
||||||
Body: body,
|
|
||||||
}
|
|
||||||
return post, nil
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user