A fast and simple blog backend.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
mediocre-blog/srv/src/post/post.go

27 lines
624 B

// 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
}