From 06d17d98b34c6daf786aa808f73e6f4692d50da0 Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Mon, 10 Apr 2017 18:47:41 -0700 Subject: tag wip --- post/post.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'post') diff --git a/post/post.go b/post/post.go index 6ce195b..7a6f478 100644 --- a/post/post.go +++ b/post/post.go @@ -37,6 +37,7 @@ type Post struct { Day int InFuture bool WordCount int + Tags []string // Content text -- raw, unprocessed, unfiltered markdown Text string @@ -108,7 +109,7 @@ Title, date and other metadata are derived */ func (p *Post) parse() { // - // Text + Meta[string][string] + // fills p.Text, p.Meta[string][string] // p.splitTextMeta() @@ -116,7 +117,7 @@ func (p *Post) parse() { // Title // p.Title = p.Meta["title"] - // Use filename as backup fi we have no explicit title + // Use filename as backup if we have no explicit title if p.Title == "" { p.Title = p.SourceFile } @@ -131,6 +132,14 @@ func (p *Post) parse() { // WordCount p.WordCount = len(strings.Split(p.Text, " ")) + + // Tags + if p.Meta["tags"] != "" { + tags := strings.Split(p.Meta["tags"], ",") + for _, tag := range tags { + p.Tags = append(p.Tags, strings.TrimSpace(tag)) + } + } } /* @@ -213,7 +222,6 @@ func (p *Post) parseDates() { p.Permalink = p.GenPermalink() } - func (p *Post) CleanFilename() string { return text.SanitizeFilename(text.RemoveExt(p.SourceFile)) } -- cgit v1.2.3