diff options
author | Adam Mathes <adam@trenchant.org> | 2017-04-10 18:47:41 -0700 |
---|---|---|
committer | Adam Mathes <adam@trenchant.org> | 2017-04-10 18:47:41 -0700 |
commit | 06d17d98b34c6daf786aa808f73e6f4692d50da0 (patch) | |
tree | 4c891512b24cb3a686cdbcd3e0f412d439eded32 /post | |
parent | 0bde21f3da1152eeaea0a8f712f7244b26d5df02 (diff) | |
download | snkt-06d17d98b34c6daf786aa808f73e6f4692d50da0.tar.gz snkt-06d17d98b34c6daf786aa808f73e6f4692d50da0.tar.bz2 snkt-06d17d98b34c6daf786aa808f73e6f4692d50da0.zip |
tag wip
Diffstat (limited to 'post')
-rw-r--r-- | post/post.go | 14 |
1 files changed, 11 insertions, 3 deletions
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)) } |