aboutsummaryrefslogtreecommitdiffstats
path: root/post/post.go
diff options
context:
space:
mode:
authorAdam Mathes <adam@trenchant.org>2017-04-16 12:05:58 -0700
committerAdam Mathes <adam@trenchant.org>2017-04-16 12:05:58 -0700
commitaee32aafdfe313be5b5fff21866e4bd562a7e545 (patch)
treec9014a9ba9076837cd15fd3bb198143703b5886f /post/post.go
parent06d17d98b34c6daf786aa808f73e6f4692d50da0 (diff)
downloadsnkt-aee32aafdfe313be5b5fff21866e4bd562a7e545.tar.gz
snkt-aee32aafdfe313be5b5fff21866e4bd562a7e545.tar.bz2
snkt-aee32aafdfe313be5b5fff21866e4bd562a7e545.zip
tags support wip
Diffstat (limited to 'post/post.go')
-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() {