hugo: github.com/gohugoio/hugo/resources/page Index | Files | Directories

package page

import "github.com/gohugoio/hugo/resources/page"

Package page contains the core interfaces and types for the Page resource, a core component in Hugo.

Package page contains the core interfaces and types for the Page resource, a core component in Hugo.

Package page contains the core interfaces and types for the Page resource, a core component in Hugo.

Package page contains the core interfaces and types for the Page resource, a core component in Hugo.

Index

Package Files

page.go page_author.go page_data.go page_kinds.go page_marshaljson.autogen.go page_nop.go page_outputformat.go page_paths.go page_wrappers.autogen.go pagegroup.go pages.go pages_cache.go pages_language_merge.go pages_prev_next.go pages_related.go pages_sort.go pages_sort_search.go pagination.go permalinks.go site.go weighted.go zero_file.autogen.go

Constants

const (
    KindPage = "page"

    KindHome         = "home"
    KindSection      = "section"
    KindTaxonomy     = "taxonomy"
    KindTaxonomyTerm = "taxonomyTerm"
)

Variables

var (
    NopPage Page = new(nopPage)
    NilPage *nopPage
)
var (

    // DefaultPageSort is the default sort func for pages in Hugo:
    // Order by Weight, Date, LinkTitle and then full file path.
    DefaultPageSort = func(p1, p2 Page) bool {
        if p1.Weight() == p2.Weight() {
            if p1.Date().Unix() == p2.Date().Unix() {
                c := compare.Strings(p1.LinkTitle(), p2.LinkTitle())
                if c == 0 {
                    if p1.File().IsZero() || p2.File().IsZero() {
                        return p1.File().IsZero()
                    }
                    return compare.LessStrings(p1.File().Filename(), p2.File().Filename())
                }
                return c < 0
            }
            return p1.Date().Unix() > p2.Date().Unix()
        }

        if p2.Weight() == 0 {
            return true
        }

        if p1.Weight() == 0 {
            return false
        }

        return p1.Weight() < p2.Weight()
    }
)

func Clear Uses

func Clear() error

Clear clears any global package state.

func GetKind Uses

func GetKind(s string) string

GetKind gets the page kind given a string, empty if not found.

func MarshalPageToJSON Uses

func MarshalPageToJSON(p Page) ([]byte, error)

func NewZeroFile Uses

func NewZeroFile(log *helpers.DistinctLogger) source.File

func ResolvePagerSize Uses

func ResolvePagerSize(cfg config.Provider, options ...interface{}) (int, error)

func SortByDefault Uses

func SortByDefault(pages Pages)

SortByDefault sorts pages by the default sort.

func SortByLanguage Uses

func SortByLanguage(pages Pages)

SortByLanguage sorts the pages by language.

type AlternativeOutputFormatsProvider Uses

type AlternativeOutputFormatsProvider interface {
    // AlternativeOutputFormats gives the alternative output formats for the
    // current output.
    // Note that we use the term "alternative" and not "alternate" here, as it
    // does not necessarily replace the other format, it is an alternative representation.
    AlternativeOutputFormats() OutputFormats
}

AlternativeOutputFormatsProvider provides alternative output formats for a Page.

type Author Uses

type Author struct {
    GivenName   string
    FamilyName  string
    DisplayName string
    Thumbnail   string
    Image       string
    ShortBio    string
    LongBio     string
    Email       string
    Social      AuthorSocial
}

Author contains details about the author of a page.

type AuthorList Uses

type AuthorList map[string]Author

AuthorList is a list of all authors and their metadata.

type AuthorProvider Uses

type AuthorProvider interface {
    Author() Author
    Authors() AuthorList
}

AuthorProvider provides author information.

type AuthorSocial Uses

type AuthorSocial map[string]string

AuthorSocial is a place to put social details per author. These are the standard keys that themes will expect to have available, but can be expanded to any others on a per site basis - website - github - facebook - twitter - pinterest - instagram - youtube - linkedin - skype

type ChildCareProvider Uses

type ChildCareProvider interface {
    Pages() Pages

    // RegularPages returns a list of pages of kind 'Page'.
    // In Hugo 0.57 we changed the Pages method so it returns all page
    // kinds, even sections. If you want the old behaviour, you can
    // use RegularPages.
    RegularPages() Pages

    // RegularPagesRecursive returns all regular pages below the current
    // section.
    RegularPagesRecursive() Pages

    Resources() resource.Resources
}

ChildCareProvider provides accessors to child resources.

type ContentProvider Uses

type ContentProvider interface {
    Content() (interface{}, error)
    Plain() string
    PlainWords() []string
    Summary() template.HTML
    Truncated() bool
    FuzzyWordCount() int
    WordCount() int
    ReadingTime() int
    Len() int
}

ContentProvider provides the content related values for a Page.

type Data Uses

type Data map[string]interface{}

Data represents the .Data element in a Page in Hugo. We make this a type so we can do lazy loading of .Data.Pages

func (Data) Pages Uses

func (d Data) Pages() Pages

Pages returns the pages stored with key "pages". If this is a func, it will be invoked.

type DeprecatedErrorPageMethods Uses

type DeprecatedErrorPageMethods interface {
}

Move here to trigger ERROR instead of WARNING. TODO(bep) create wrappers and put into the Page once it has some methods.

type DeprecatedWarningPageMethods Uses

type DeprecatedWarningPageMethods interface {
    source.FileWithoutOverlap
    DeprecatedWarningPageMethods1
}

DeprecatedWarningPageMethods lists deprecated Page methods that will trigger a WARNING if invoked. This was added in Hugo 0.55.

func NewDeprecatedWarningPage Uses

func NewDeprecatedWarningPage(p DeprecatedWarningPageMethods) DeprecatedWarningPageMethods

NewDeprecatedWarningPage adds deprecation warnings to the given implementation.

type DeprecatedWarningPageMethods1 Uses

type DeprecatedWarningPageMethods1 interface {
    IsDraft() bool
    Hugo() hugo.Info
    LanguagePrefix() string
    GetParam(key string) interface{}
    RSSLink() template.URL
    URL() string
}

type FileProvider Uses

type FileProvider interface {
    File() source.File
}

FileProvider provides the source file.

type GetPageProvider Uses

type GetPageProvider interface {
    // GetPage looks up a page for the given ref.
    //    {{ with .GetPage "blog" }}{{ .Title }}{{ end }}
    //
    // This will return nil when no page could be found, and will return
    // an error if the ref is ambiguous.
    GetPage(ref string) (Page, error)
}

GetPageProvider provides the GetPage method.

type GitInfoProvider Uses

type GitInfoProvider interface {
    GitInfo() *gitmap.GitInfo
}

GitInfoProvider provides Git info.

type InSectionPositioner Uses

type InSectionPositioner interface {
    NextInSection() Page
    PrevInSection() Page
}

InSectionPositioner provides section navigation.

type InternalDependencies Uses

type InternalDependencies interface {
    GetRelatedDocsHandler() *RelatedDocsHandler
}

InternalDependencies is considered an internal interface.

type OutputFormat Uses

type OutputFormat struct {
    // Rel constains a value that can be used to construct a rel link.
    // This is value is fetched from the output format definition.
    // Note that for pages with only one output format,
    // this method will always return "canonical".
    // As an example, the AMP output format will, by default, return "amphtml".
    //
    // See:
    // https://www.ampproject.org/docs/guides/deploy/discovery
    //
    // Most other output formats will have "alternate" as value for this.
    Rel string

    Format output.Format
    // contains filtered or unexported fields
}

OutputFormat links to a representation of a resource.

func NewOutputFormat Uses

func NewOutputFormat(relPermalink, permalink string, isCanonical bool, f output.Format) OutputFormat

func (OutputFormat) MediaType Uses

func (o OutputFormat) MediaType() media.Type

MediaType returns this OutputFormat's MediaType (MIME type).

func (OutputFormat) Name Uses

func (o OutputFormat) Name() string

Name returns this OutputFormat's name, i.e. HTML, AMP, JSON etc.

func (o OutputFormat) Permalink() string

Permalink returns the absolute permalink to this output format.

func (o OutputFormat) RelPermalink() string

RelPermalink returns the relative permalink to this output format.

type OutputFormats Uses

type OutputFormats []OutputFormat

OutputFormats holds a list of the relevant output formats for a given page.

func (OutputFormats) Get Uses

func (o OutputFormats) Get(name string) *OutputFormat

Get gets a OutputFormat given its name, i.e. json, html etc. It returns nil if none found.

type OutputFormatsProvider Uses

type OutputFormatsProvider interface {
    OutputFormats() OutputFormats
}

OutputFormatsProvider provides the OutputFormats of a Page.

type Page Uses

type Page interface {
    ContentProvider
    TableOfContentsProvider
    PageWithoutContent
}

Page is the core interface in Hugo.

type PageGenealogist Uses

type PageGenealogist interface {

    // Template example:
    // {{ $related := .RegularPages.Related . }}
    Related(doc related.Document) (Pages, error)

    // Template example:
    // {{ $related := .RegularPages.RelatedIndices . "tags" "date" }}
    RelatedIndices(doc related.Document, indices ...interface{}) (Pages, error)

    // Template example:
    // {{ $related := .RegularPages.RelatedTo ( keyVals "tags" "hugo", "rocks")  ( keyVals "date" .Date ) }}
    RelatedTo(args ...types.KeyValues) (Pages, error)
}

A PageGenealogist finds related pages in a page collection. This interface is implemented by Pages and PageGroup, which makes it available as `{{ .RegularRelated . }}` etc.

type PageGroup Uses

type PageGroup struct {
    Key interface{}
    Pages
}

PageGroup represents a group of pages, grouped by the key. The key is typically a year or similar.

func (PageGroup) ProbablyEq Uses

func (p PageGroup) ProbablyEq(other interface{}) bool

ProbablyEq wraps comare.ProbablyEqer

func (PageGroup) Slice Uses

func (p PageGroup) Slice(in interface{}) (interface{}, error)

Slice is not meant to be used externally. It's a bridge function for the template functions. See collections.Slice.

type PageMetaProvider Uses

type PageMetaProvider interface {
    // The 4 page dates
    resource.Dated

    // Aliases forms the base for redirects generation.
    Aliases() []string

    // BundleType returns the bundle type: "leaf", "branch" or an empty string if it is none.
    // See https://gohugo.io/content-management/page-bundles/
    BundleType() files.ContentClass

    // A configured description.
    Description() string

    // Whether this is a draft. Will only be true if run with the --buildDrafts (-D) flag.
    Draft() bool

    // IsHome returns whether this is the home page.
    IsHome() bool

    // Configured keywords.
    Keywords() []string

    // The Page Kind. One of page, home, section, taxonomy, taxonomyTerm.
    Kind() string

    // The configured layout to use to render this page. Typically set in front matter.
    Layout() string

    // The title used for links.
    LinkTitle() string

    // IsNode returns whether this is an item of one of the list types in Hugo,
    // i.e. not a regular content
    IsNode() bool

    // IsPage returns whether this is a regular content
    IsPage() bool

    // Param looks for a param in Page and then in Site config.
    Param(key interface{}) (interface{}, error)

    // Path gets the relative path, including file name and extension if relevant,
    // to the source of this Page. It will be relative to any content root.
    Path() string

    // The slug, typically defined in front matter.
    Slug() string

    // This page's language code. Will be the same as the site's.
    Lang() string

    // IsSection returns whether this is a section
    IsSection() bool

    // Section returns the first path element below the content root.
    Section() string

    // Returns a slice of sections (directories if it's a file) to this
    // Page.
    SectionsEntries() []string

    // SectionsPath is SectionsEntries joined with a /.
    SectionsPath() string

    // Sitemap returns the sitemap configuration for this page.
    Sitemap() config.Sitemap

    // Type is a discriminator used to select layouts etc. It is typically set
    // in front matter, but will fall back to the root section.
    Type() string

    // The configured weight, used as the first sort value in the default
    // page sort if non-zero.
    Weight() int
}

PageMetaProvider provides page metadata, typically provided via front matter.

type PageRenderProvider Uses

type PageRenderProvider interface {
    Render(layout ...string) (template.HTML, error)
    RenderString(args ...interface{}) (template.HTML, error)
}

PageRenderProvider provides a way for a Page to render content.

type PageWithoutContent Uses

type PageWithoutContent interface {
    RawContentProvider
    resource.Resource
    PageMetaProvider
    resource.LanguageProvider

    // For pages backed by a file.
    FileProvider

    GitInfoProvider

    // Output formats
    OutputFormatsProvider
    AlternativeOutputFormatsProvider

    // Tree navigation
    ChildCareProvider
    TreeProvider

    // Horizontal navigation
    InSectionPositioner
    PageRenderProvider
    PaginatorProvider
    Positioner
    navigation.PageMenusProvider

    // TODO(bep)
    AuthorProvider

    // Page lookups/refs
    GetPageProvider
    RefProvider

    resource.TranslationKeyProvider
    TranslationsProvider

    SitesProvider

    // Helper methods
    ShortcodeInfoProvider
    compare.Eqer
    maps.Scratcher
    RelatedKeywordsProvider

    // GetTerms gets the terms of a given taxonomy,
    // e.g. GetTerms("categories")
    GetTerms(taxonomy string) Pages

    DeprecatedWarningPageMethods
}

PageWithoutContent is the Page without any of the content methods.

type Pager Uses

type Pager struct {
    *Paginator
    // contains filtered or unexported fields
}

Pager represents one of the elements in a paginator. The number, starting on 1, represents its place.

func (*Pager) First Uses

func (p *Pager) First() *Pager

First returns the pager for the first page.

func (*Pager) HasNext Uses

func (p *Pager) HasNext() bool

HasNext tests whether there are page(s) after the current.

func (*Pager) HasPrev Uses

func (p *Pager) HasPrev() bool

HasPrev tests whether there are page(s) before the current.

func (*Pager) Last Uses

func (p *Pager) Last() *Pager

Last returns the pager for the last page.

func (*Pager) Next Uses

func (p *Pager) Next() *Pager

Next returns the pager for the next page.

func (*Pager) NumberOfElements Uses

func (p *Pager) NumberOfElements() int

NumberOfElements gets the number of elements on this page.

func (*Pager) PageGroups Uses

func (p *Pager) PageGroups() PagesGroup

PageGroups return Page groups for this page. Note: If this return non-empty result, then Pages() will return empty.

func (*Pager) PageNumber Uses

func (p *Pager) PageNumber() int

PageNumber returns the current page's number in the pager sequence.

func (*Pager) Pages Uses

func (p *Pager) Pages() Pages

Pages returns the Pages on this page. Note: If this return a non-empty result, then PageGroups() will return empty.

func (*Pager) Prev Uses

func (p *Pager) Prev() *Pager

Prev returns the pager for the previous page.

func (Pager) String Uses

func (p Pager) String() string

func (*Pager) URL Uses

func (p *Pager) URL() template.HTML

URL returns the URL to the current page.

type Pages Uses

type Pages []Page

Pages is a slice of pages. This is the most common list type in Hugo.

func ToPages Uses

func ToPages(seq interface{}) (Pages, error)

ToPages tries to convert seq into Pages.

func (Pages) ByDate Uses

func (p Pages) ByDate() Pages

ByDate sorts the Pages by date and returns a copy.

Adjacent invocations on the same receiver will return a cached result.

This may safely be executed in parallel.

func (Pages) ByExpiryDate Uses

func (p Pages) ByExpiryDate() Pages

ByExpiryDate sorts the Pages by publish date and returns a copy.

Adjacent invocations on the same receiver will return a cached result.

This may safely be executed in parallel.

func (Pages) ByLanguage Uses

func (p Pages) ByLanguage() Pages

ByLanguage sorts the Pages by the language's Weight.

Adjacent invocations on the same receiver will return a cached result.

This may safely be executed in parallel.

func (Pages) ByLastmod Uses

func (p Pages) ByLastmod() Pages

ByLastmod sorts the Pages by the last modification date and returns a copy.

Adjacent invocations on the same receiver will return a cached result.

This may safely be executed in parallel.

func (Pages) ByLength Uses

func (p Pages) ByLength() Pages

ByLength sorts the Pages by length and returns a copy.

Adjacent invocations on the same receiver will return a cached result.

This may safely be executed in parallel.

func (Pages) ByLinkTitle Uses

func (p Pages) ByLinkTitle() Pages

ByLinkTitle sorts the Pages by link title and returns a copy.

Adjacent invocations on the same receiver will return a cached result.

This may safely be executed in parallel.

func (Pages) ByParam Uses

func (p Pages) ByParam(paramsKey interface{}) Pages

ByParam sorts the pages according to the given page Params key.

Adjacent invocations on the same receiver with the same paramsKey will return a cached result.

This may safely be executed in parallel.

func (Pages) ByPublishDate Uses

func (p Pages) ByPublishDate() Pages

ByPublishDate sorts the Pages by publish date and returns a copy.

Adjacent invocations on the same receiver will return a cached result.

This may safely be executed in parallel.

func (Pages) ByTitle Uses

func (p Pages) ByTitle() Pages

ByTitle sorts the Pages by title and returns a copy.

Adjacent invocations on the same receiver will return a cached result.

This may safely be executed in parallel.

func (Pages) ByWeight Uses

func (p Pages) ByWeight() Pages

ByWeight sorts the Pages by weight and returns a copy.

Adjacent invocations on the same receiver will return a cached result.

This may safely be executed in parallel.

func (Pages) Group Uses

func (p Pages) Group(key interface{}, in interface{}) (interface{}, error)

func (Pages) GroupBy Uses

func (p Pages) GroupBy(key string, order ...string) (PagesGroup, error)

GroupBy groups by the value in the given field or method name and with the given order. Valid values for order is asc, desc, rev and reverse.

func (Pages) GroupByDate Uses

func (p Pages) GroupByDate(format string, order ...string) (PagesGroup, error)

GroupByDate groups by the given page's Date value in the given format and with the given order. Valid values for order is asc, desc, rev and reverse. For valid format strings, see https://golang.org/pkg/time/#Time.Format

func (Pages) GroupByExpiryDate Uses

func (p Pages) GroupByExpiryDate(format string, order ...string) (PagesGroup, error)

GroupByExpiryDate groups by the given page's ExpireDate value in the given format and with the given order. Valid values for order is asc, desc, rev and reverse. For valid format strings, see https://golang.org/pkg/time/#Time.Format

func (Pages) GroupByParam Uses

func (p Pages) GroupByParam(key string, order ...string) (PagesGroup, error)

GroupByParam groups by the given page parameter key's value and with the given order. Valid values for order is asc, desc, rev and reverse.

func (Pages) GroupByParamDate Uses

func (p Pages) GroupByParamDate(key string, format string, order ...string) (PagesGroup, error)

GroupByParamDate groups by a date set as a param on the page in the given format and with the given order. Valid values for order is asc, desc, rev and reverse. For valid format strings, see https://golang.org/pkg/time/#Time.Format

func (Pages) GroupByPublishDate Uses

func (p Pages) GroupByPublishDate(format string, order ...string) (PagesGroup, error)

GroupByPublishDate groups by the given page's PublishDate value in the given format and with the given order. Valid values for order is asc, desc, rev and reverse. For valid format strings, see https://golang.org/pkg/time/#Time.Format

func (Pages) Len Uses

func (p Pages) Len() int

Len returns the number of pages in the list.

func (Pages) Limit Uses

func (p Pages) Limit(n int) Pages

Limit limits the number of pages returned to n.

func (Pages) MergeByLanguage Uses

func (p1 Pages) MergeByLanguage(p2 Pages) Pages

MergeByLanguage supplies missing translations in p1 with values from p2. The result is sorted by the default sort order for pages.

func (Pages) MergeByLanguageInterface Uses

func (p1 Pages) MergeByLanguageInterface(in interface{}) (interface{}, error)

MergeByLanguageInterface is the generic version of MergeByLanguage. It is here just so it can be called from the tpl package.

func (Pages) Next Uses

func (p Pages) Next(cur Page) Page

Next returns the next page reletive to the given

func (Pages) Prev Uses

func (p Pages) Prev(cur Page) Page

Prev returns the previous page reletive to the given

func (Pages) ProbablyEq Uses

func (pages Pages) ProbablyEq(other interface{}) bool

ProbablyEq wraps comare.ProbablyEqer

func (Pages) Related Uses

func (p Pages) Related(doc related.Document) (Pages, error)

Related searches all the configured indices with the search keywords from the supplied document.

func (Pages) RelatedIndices Uses

func (p Pages) RelatedIndices(doc related.Document, indices ...interface{}) (Pages, error)

RelatedIndices searches the given indices with the search keywords from the supplied document.

func (Pages) RelatedTo Uses

func (p Pages) RelatedTo(args ...types.KeyValues) (Pages, error)

RelatedTo searches the given indices with the corresponding values.

func (Pages) Reverse Uses

func (p Pages) Reverse() Pages

Reverse reverses the order in Pages and returns a copy.

Adjacent invocations on the same receiver will return a cached result.

This may safely be executed in parallel.

func (Pages) String Uses

func (ps Pages) String() string

func (Pages) ToResources Uses

func (pages Pages) ToResources() resource.Resources

ToResources wraps resource.ResourcesConverter

type PagesFactory Uses

type PagesFactory func() Pages

PagesFactory somehow creates some Pages. We do a lot of lazy Pages initialization in Hugo, so we need a type.

type PagesGroup Uses

type PagesGroup []PageGroup

PagesGroup represents a list of page groups. This is what you get when doing page grouping in the templates.

func ToPagesGroup Uses

func ToPagesGroup(seq interface{}) (PagesGroup, error)

ToPagesGroup tries to convert seq into a PagesGroup.

func (PagesGroup) Len Uses

func (psg PagesGroup) Len() int

Len returns the number of pages in the page group.

func (PagesGroup) ProbablyEq Uses

func (psg PagesGroup) ProbablyEq(other interface{}) bool

ProbablyEq wraps comare.ProbablyEqer

func (PagesGroup) Reverse Uses

func (p PagesGroup) Reverse() PagesGroup

Reverse reverses the order of this list of page groups.

type Paginator Uses

type Paginator struct {
    // contains filtered or unexported fields
}

func Paginate Uses

func Paginate(td TargetPathDescriptor, seq interface{}, pagerSize int) (*Paginator, error)

func (*Paginator) PageSize Uses

func (p *Paginator) PageSize() int

PageSize returns the size of each paginator page.

func (*Paginator) Pagers Uses

func (p *Paginator) Pagers() pagers

Pagers returns a list of pagers that can be used to build a pagination menu.

func (*Paginator) TotalNumberOfElements Uses

func (p *Paginator) TotalNumberOfElements() int

TotalNumberOfElements returns the number of elements on all pages in this paginator.

func (*Paginator) TotalPages Uses

func (p *Paginator) TotalPages() int

TotalPages returns the number of pages in the paginator.

type PaginatorProvider Uses

type PaginatorProvider interface {
    Paginator(options ...interface{}) (*Pager, error)
    Paginate(seq interface{}, options ...interface{}) (*Pager, error)
}

PaginatorProvider provides two ways to create a page paginator.

type PermalinkExpander Uses

type PermalinkExpander struct {
    // contains filtered or unexported fields
}

PermalinkExpander holds permalin mappings per section.

func NewPermalinkExpander Uses

func NewPermalinkExpander(ps *helpers.PathSpec) (PermalinkExpander, error)

NewPermalinkExpander creates a new PermalinkExpander configured by the given PathSpec.

func (PermalinkExpander) Expand Uses

func (l PermalinkExpander) Expand(key string, p Page) (string, error)

Expand expands the path in p according to the rules defined for the given key. If no rules are found for the given key, an empty string is returned.

type Positioner Uses

type Positioner interface {
    Next() Page
    Prev() Page

    // Deprecated: Use Prev. Will be removed in Hugo 0.57
    PrevPage() Page

    // Deprecated: Use Next. Will be removed in Hugo 0.57
    NextPage() Page
}

Positioner provides next/prev navigation.

type RawContentProvider Uses

type RawContentProvider interface {
    RawContent() string
}

RawContentProvider provides the raw, unprocessed content of the page.

type RefProvider Uses

type RefProvider interface {
    Ref(argsm map[string]interface{}) (string, error)
    RefFrom(argsm map[string]interface{}, source interface{}) (string, error)
    RelRef(argsm map[string]interface{}) (string, error)
    RelRefFrom(argsm map[string]interface{}, source interface{}) (string, error)
}

RefProvider provides the methods needed to create reflinks to pages.

type RelatedDocsHandler Uses

type RelatedDocsHandler struct {
    // contains filtered or unexported fields
}

func NewRelatedDocsHandler Uses

func NewRelatedDocsHandler(cfg related.Config) *RelatedDocsHandler

func (*RelatedDocsHandler) Clone Uses

func (s *RelatedDocsHandler) Clone() *RelatedDocsHandler

type RelatedKeywordsProvider Uses

type RelatedKeywordsProvider interface {
    // Make it indexable as a related.Document
    RelatedKeywords(cfg related.IndexConfig) ([]related.Keyword, error)
}

RelatedKeywordsProvider allows a Page to be indexed.

type ShortcodeInfoProvider Uses

type ShortcodeInfoProvider interface {
    // HasShortcode return whether the page has a shortcode with the given name.
    // This method is mainly motivated with the Hugo Docs site's need for a list
    // of pages with the `todo` shortcode in it.
    HasShortcode(name string) bool
}

ShortcodeInfoProvider provides info about the shortcodes in a Page.

type Site Uses

type Site interface {
    Language() *langs.Language
    RegularPages() Pages
    Pages() Pages
    IsServer() bool
    ServerPort() int
    Title() string
    Sites() Sites
    Hugo() hugo.Info
    BaseURL() template.URL
    Taxonomies() interface{}
    LastChange() time.Time
    Menus() navigation.Menus
    Params() maps.Params
    Data() map[string]interface{}
}

Site represents a site in the build. This is currently a very narrow interface, but the actual implementation will be richer, see hugolib.SiteInfo.

func NewDummyHugoSite Uses

func NewDummyHugoSite(cfg config.Provider) Site

NewDummyHugoSite creates a new minimal test site.

type Sites Uses

type Sites []Site

Sites represents an ordered list of sites (languages).

func (Sites) First Uses

func (s Sites) First() Site

First is a convenience method to get the first Site, i.e. the main language.

type SitesProvider Uses

type SitesProvider interface {
    Site() Site
    Sites() Sites
}

SitesProvider provide accessors to get sites.

type TableOfContentsProvider Uses

type TableOfContentsProvider interface {
    TableOfContents() template.HTML
}

TableOfContentsProvider provides the table of contents for a Page.

type TargetPathDescriptor Uses

type TargetPathDescriptor struct {
    PathSpec *helpers.PathSpec

    Type output.Format
    Kind string

    Sections []string

    // For regular content pages this is either
    // 1) the Slug, if set,
    // 2) the file base name (TranslationBaseName).
    BaseName string

    // Source directory.
    Dir string

    // Typically a language prefix added to file paths.
    PrefixFilePath string

    // Typically a language prefix added to links.
    PrefixLink string

    // If in multihost mode etc., every link/path needs to be prefixed, even
    // if set in URL.
    ForcePrefix bool

    // URL from front matter if set. Will override any Slug etc.
    URL string

    // Used to create paginator links.
    Addends string

    // The expanded permalink if defined for the section, ready to use.
    ExpandedPermalink string

    // Some types cannot have uglyURLs, even if globally enabled, RSS being one example.
    UglyURLs bool
}

TargetPathDescriptor describes how a file path for a given resource should look like on the file system. The same descriptor is then later used to create both the permalinks and the relative links, paginator URLs etc.

The big motivating behind this is to have only one source of truth for URLs, and by that also get rid of most of the fragile string parsing/encoding etc.

type TargetPaths Uses

type TargetPaths struct {

    // Where to store the file on disk relative to the publish dir. OS slashes.
    TargetFilename string

    // The directory to write sub-resources of the above.
    SubResourceBaseTarget string

    // The base for creating links to sub-resources of the above.
    SubResourceBaseLink string

    // The relative permalink to this resources. Unix slashes.
    Link string
}

TODO(bep) move this type.

func CreateTargetPaths Uses

func CreateTargetPaths(d TargetPathDescriptor) (tp TargetPaths)

func (TargetPaths) PermalinkForOutputFormat Uses

func (p TargetPaths) PermalinkForOutputFormat(s *helpers.PathSpec, f output.Format) string
func (p TargetPaths) RelPermalink(s *helpers.PathSpec) string

type TranslationsProvider Uses

type TranslationsProvider interface {

    // IsTranslated returns whether this content file is translated to
    // other language(s).
    IsTranslated() bool

    // AllTranslations returns all translations, including the current Page.
    AllTranslations() Pages

    // Translations returns the translations excluding the current Page.
    Translations() Pages
}

TranslationsProvider provides access to any translations.

type TreeProvider Uses

type TreeProvider interface {

    // IsAncestor returns whether the current page is an ancestor of the given
    // Note that this method is not relevant for taxonomy lists and taxonomy terms pages.
    IsAncestor(other interface{}) (bool, error)

    // CurrentSection returns the page's current section or the page itself if home or a section.
    // Note that this will return nil for pages that is not regular, home or section pages.
    CurrentSection() Page

    // IsDescendant returns whether the current page is a descendant of the given
    // Note that this method is not relevant for taxonomy lists and taxonomy terms pages.
    IsDescendant(other interface{}) (bool, error)

    // FirstSection returns the section on level 1 below home, e.g. "/docs".
    // For the home page, this will return itself.
    FirstSection() Page

    // InSection returns whether the given page is in the current section.
    // Note that this will always return false for pages that are
    // not either regular, home or section pages.
    InSection(other interface{}) (bool, error)

    // Parent returns a section's parent section or a page's section.
    // To get a section's subsections, see Page's Sections method.
    Parent() Page

    // Sections returns this section's subsections, if any.
    // Note that for non-sections, this method will always return an empty list.
    Sections() Pages

    // Page returns a reference to the Page itself, kept here mostly
    // for legacy reasons.
    Page() Page
}

TreeProvider provides section tree navigation.

type WeightedPage Uses

type WeightedPage struct {
    Weight int
    Page
    // contains filtered or unexported fields
}

A WeightedPage is a Page with a weight.

func NewWeightedPage Uses

func NewWeightedPage(weight int, p Page, owner Page) WeightedPage

func (WeightedPage) Slice Uses

func (p WeightedPage) Slice(in interface{}) (interface{}, error)

Slice is not meant to be used externally. It's a bridge function for the template functions. See collections.Slice.

func (WeightedPage) String Uses

func (w WeightedPage) String() string

type WeightedPages Uses

type WeightedPages []WeightedPage

WeightedPages is a list of Pages with their corresponding (and relative) weight [{Weight: 30, Page: *1}, {Weight: 40, Page: *2}]

func (WeightedPages) Count Uses

func (wp WeightedPages) Count() int

Count returns the number of pages in this weighted page set.

func (WeightedPages) Len Uses

func (wp WeightedPages) Len() int

func (WeightedPages) Less Uses

func (wp WeightedPages) Less(i, j int) bool

func (WeightedPages) Next Uses

func (wp WeightedPages) Next(cur Page) Page

Next returns the next Page relative to the given Page in this weighted page set.

func (WeightedPages) Page Uses

func (p WeightedPages) Page() Page

Page will return the Page (of Kind taxonomyList) that represents this set of pages. This method will panic if p is empty, as that should never happen.

func (WeightedPages) Pages Uses

func (wp WeightedPages) Pages() Pages

Pages returns the Pages in this weighted page set.

func (WeightedPages) Prev Uses

func (wp WeightedPages) Prev(cur Page) Page

Prev returns the previous Page relative to the given Page in this weighted page set.

func (WeightedPages) Sort Uses

func (wp WeightedPages) Sort()

Sort stable sorts this weighted page set.

func (WeightedPages) Swap Uses

func (wp WeightedPages) Swap(i, j int)

Directories

PathSynopsis
page_generate
pagemeta

Package page imports 35 packages (graph) and is imported by 52 packages. Updated 2020-03-24. Refresh now. Tools for package owners.