Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Only include matches >= threshold, a normalized rank between 0 and 100. Threshold int // To get stable "See also" sections we, by default, exclude newer related pages. IncludeNewer bool // Will lower case all string values and queries to the indices. // May get better results, but at a slight performance cost. ToLower bool Indices IndexConfigs }
Config is the top level configuration element used to configure how to retrieve related content in Hugo.
An example site config.toml:
[related] threshold = 1 [[related.indices]] name = "keywords" weight = 200 [[related.indices]] name = "tags" weight = 100 [[related.indices]] name = "date" weight = 1 pattern = "2006"
type Document ¶
type Document interface { // RelatedKeywords returns a list of keywords for the given index config. RelatedKeywords(cfg IndexConfig) ([]Keyword, error) // When this document was or will be published. PublishDate() time.Time // Name is used as an tiebreaker if both Weight and PublishDate are // the same. Name() string }
Document is the interface an indexable document in Hugo must fulfill.
type IndexConfig ¶
type IndexConfig struct { // The index name. This directly maps to a field or Param name. Name string // Contextual pattern used to convert the Param value into a string. // Currently only used for dates. Can be used to, say, bump posts in the same // time frame when searching for related documents. // For dates it follows Go's time.Format patterns, i.e. // "2006" for YYYY and "200601" for YYYYMM. Pattern string // This field's weight when doing multi-index searches. Higher is "better". Weight int // Will lower case all string values in and queries tothis index. // May get better accurate results, but at a slight performance cost. ToLower bool }
IndexConfig configures an index.
func (IndexConfig) ToKeywords ¶
func (cfg IndexConfig) ToKeywords(v any) ([]Keyword, error)
ToKeywords returns a Keyword slice of the given input.
type IndexConfigs ¶
type IndexConfigs []IndexConfig
IndexConfigs holds a set of index configurations.
type InvertedIndex ¶
type InvertedIndex struct {
// contains filtered or unexported fields
}
InvertedIndex holds an inverted index, also sometimes named posting list, which lists, for every possible search term, the documents that contain that term.
type Keyword ¶
type Keyword interface {
String() string
}
Keyword is the interface a keyword in the search index must implement.
func StringsToKeywords ¶
StringsToKeywords converts the given slice of strings to a slice of Keyword.
type StringKeyword ¶
type StringKeyword string
StringKeyword is a string search keyword.
func (StringKeyword) String ¶
func (s StringKeyword) String() string