aboutsummaryrefslogtreecommitdiffstats
path: root/post
diff options
context:
space:
mode:
Diffstat (limited to 'post')
-rw-r--r--post/post.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/post/post.go b/post/post.go
index 7a6f478..792635f 100644
--- a/post/post.go
+++ b/post/post.go
@@ -134,15 +134,24 @@ 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]
*/
func (p *Post) splitTextMeta() {