mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-26 22:04:32 +02:00
@@ -16,8 +16,6 @@ package hugolib
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"github.com/spf13/hugo/helpers"
|
||||
)
|
||||
|
||||
// The TaxonomyList is a list of all taxonomies and their values
|
||||
@@ -59,26 +57,15 @@ type OrderedTaxonomyEntry struct {
|
||||
WeightedPages WeightedPages
|
||||
}
|
||||
|
||||
// KeyPrep... Taxonomies should be case insensitive. Can make it easily conditional later.
|
||||
func kp(in string) string {
|
||||
return helpers.CurrentPathSpec().MakePathSanitized(in)
|
||||
}
|
||||
|
||||
// Get the weighted pages for the given key.
|
||||
func (i Taxonomy) Get(key string) WeightedPages {
|
||||
if val, ok := i[key]; ok {
|
||||
return val
|
||||
}
|
||||
return i[kp(key)]
|
||||
return i[key]
|
||||
}
|
||||
|
||||
// Count the weighted pages for the given key.
|
||||
func (i Taxonomy) Count(key string) int { return len(i[kp(key)]) }
|
||||
func (i Taxonomy) Count(key string) int { return len(i[key]) }
|
||||
|
||||
func (i Taxonomy) add(key string, w WeightedPage, pretty bool) {
|
||||
if !pretty {
|
||||
key = kp(key)
|
||||
}
|
||||
func (i Taxonomy) add(key string, w WeightedPage) {
|
||||
i[key] = append(i[key], w)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user