package model import ( "fmt" "html/template" "regexp" "strings" "time" ) type ( Blog struct { Title string `db:"title"` Description string `db:"description"` Visible bool `db:"visible"` Date time.Time `db:"date"` AuthorID string `db:"author"` Markdown string `db:"markdown"` HTML template.HTML `db:"html"` BlueskyActorID string `db:"bsky_actor"` BlueskyPostID string `db:"bsky_post"` } ) func (b *Blog) TitleNormalised() string { rgx := regexp.MustCompile(`[^a-z0-9\-]`) return rgx.ReplaceAllString( strings.ReplaceAll( strings.ToLower(b.Title), " ", "-", ), "", ) } func (b *Blog) GetMonth() string { return fmt.Sprintf("%02d", int(b.Date.Month())) } func (b *Blog) PrintDate() string { return b.Date.Format("02 January 2006") }