예제 #1
0
// AllSlugs returns the current and all the previous article
// slugs, used for redirects.
func (a *Article) AllSlugs() []string {
	slugs := make([]string, 0, len(a.Slugs)+len(a.Titles))
	slugs = append(slugs, a.Slugs...)
	for _, v := range a.Titles {
		slugs = append(slugs, stringutil.SlugN(v, maxSlugLength))
	}
	return slugs
}
예제 #2
0
// Slug returns the current article slug.
func (a *Article) Slug() string {
	if len(a.Slugs) > 0 {
		return a.Slugs[0]
	}
	return stringutil.SlugN(a.Title(), maxSlugLength)
}