summaryrefslogtreecommitdiff
path: root/srv/src/post/post.go
blob: 7803c82acd7c28dd48588136ccd72b15e3eff74c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Package post deals with the storage and rending of blog post.
package post

import (
	"regexp"
	"strings"
)

var titleCleanRegexp = regexp.MustCompile(`[^a-z ]`)

// NewID generates a (hopefully) unique ID based on the given title.
func NewID(title string) string {
	title = strings.ToLower(title)
	title = titleCleanRegexp.ReplaceAllString(title, "")
	title = strings.ReplaceAll(title, " ", "-")
	return title
}

// Post contains all information having to do with a blog post.
type Post struct {
	ID          string
	Title       string
	Description string
	Tags        []string
	Series      string
	Body        string
}