Documentation
¶
Overview ¶
Package category supports post categories
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNotFound = errors.New("category doesn't exist")
)
Functions ¶
func HashtagFromTitle ¶
HashtagFromTitle generates a valid single-word, camelCase hashtag from a title (which might include spaces, punctuation, etc.).
Types ¶
type Category ¶
type Category struct {
ID int64 `json:"-"`
Hashtag string `json:"hashtag"`
Slug string `json:"slug"`
Title string `json:"title"`
PostCount int64 `json:"post_count"`
// IsCategory distinguishes this Category from a mere tag. If true, it is often prominently featured on a blog,
// and looked up via its Slug instead of its Hashtag. It usually has all metadata, such as Title, correctly
// populated.
IsCategory bool `json:"-"`
}
Category represents a post tag with additional metadata, like a title and slug.
func NewCategory ¶
NewCategory creates a Category you can insert into the database, based on a hashtag. It automatically breaks up the hashtag by words, based on capitalization, for both the title and a URL-friendly slug.
func NewCategoryFromPartial ¶
NewCategoryFromPartial creates a Category from a partially-populated Category, such as when a user initially creates one.
Click to show internal directories.
Click to hide internal directories.