From aee32aafdfe313be5b5fff21866e4bd562a7e545 Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Sun, 16 Apr 2017 12:05:58 -0700 Subject: tags support wip --- post/post.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'post') diff --git a/post/post.go b/post/post.go index 7a6f478..792635f 100644 --- a/post/post.go +++ b/post/post.go @@ -134,14 +134,23 @@ func (p *Post) parse() { p.WordCount = len(strings.Split(p.Text, " ")) // Tags + // TODO: separate tag stuff to other module if p.Meta["tags"] != "" { tags := strings.Split(p.Meta["tags"], ",") for _, tag := range tags { - p.Tags = append(p.Tags, strings.TrimSpace(tag)) + p.Tags = append(p.Tags, NormalizeTag(tag)) } } } +/* +NormalizeTag trims leading/ending spaces, lowercases, and replaces internal spaces with _ +*/ +func NormalizeTag(tag string) string { + t := strings.ToLower(strings.TrimSpace(tag)) + return strings.Replace(t, " ", "_", -1) +} + /* splitText splits up p.Unparsed into p.Text and p.Meta[attr][value] */ -- cgit v1.2.3