package pagemeta
import "github.com/gohugoio/hugo/resources/page/pagemeta"
Index ¶
- Constants
- Variables
- func MarkupToMediaType(s string, mediaTypes media.Types) media.Type
- type BuildConfig
- func DecodeBuildConfig(m any) (BuildConfig, error)
- func (b *BuildConfig) Disable()
- func (b BuildConfig) IsZero() bool
- type Dates
- func (d Dates) IsAllDatesZero() bool
- func (d Dates) IsDateOrLastModAfter(in Dates) bool
- func (d Dates) String() string
- func (d *Dates) UpdateDateAndLastmodAndPublishDateIfAfter(in Dates)
- type DatesStrings
- type FrontMatterDescriptor
- type FrontMatterHandler
- func NewFrontmatterHandler(logger loggers.Logger, frontMatterConfig FrontmatterConfig) (FrontMatterHandler, error)
- func (f FrontMatterHandler) HandleDates(d *FrontMatterDescriptor) error
- func (f FrontMatterHandler) IsDateKey(key string) bool
- type FrontMatterOnlyValues
- type FrontmatterConfig
- type PageConfigEarly
- func (p *PageConfigEarly) CompileEarly(pi *paths.Path, cascades *page.PageMatcherParamsConfigs, conf config.AllProvider, fim *hugofs.FileMeta, sitesMatrixBase sitesmatrix.VectorIterator, sitesMatrixBaseOnly bool, ) error
- func (p *PageConfigEarly) CompileForPagesFromDataPre(basePath string, logger loggers.Logger, mediaTypes media.Types) error
- func (p *PageConfigEarly) Init(pagesFromData bool) error
- func (pcfg *PageConfigEarly) SetMetaPreFromMap(ext string, frontmatter map[string]any, logger loggers.Logger, conf config.AllProvider) error
- type PageConfigLate
- func DefaultPageConfig() *PageConfigLate
- func (p *PageConfigLate) Compile(e *PageConfigEarly, logger loggers.Logger, outputFormats output.Formats) error
- func (p *PageConfigLate) Init() error
- type ResourceConfig
- func (rc *ResourceConfig) Compile(basePath string, fim hugofs.FileMetaInfo, conf config.AllProvider, mediaTypes media.Types) error
- func (rc *ResourceConfig) Validate() error
- type SitesMatrixAndComplements
- func (p *SitesMatrixAndComplements) MatchLanguageCoarse(siteVector sitesmatrix.Vector) bool
- func (p *SitesMatrixAndComplements) MatchRoleCoarse(siteVector sitesmatrix.Vector) bool
- func (p *SitesMatrixAndComplements) MatchSiteVector(siteVector sitesmatrix.Vector) bool
- func (p *SitesMatrixAndComplements) MatchVersionCoarse(siteVector sitesmatrix.Vector) bool
- type Source
Constants ¶
const ( Never = "never" Always = "always" ListLocally = "local" Link = "link" )
Variables ¶
var DefaultBuildConfig = BuildConfig{ List: Always, Render: Always, PublishResources: true, }
Functions ¶
func MarkupToMediaType ¶
MarkupToMediaType converts a markup string to a media type.
Types ¶
type BuildConfig ¶
type BuildConfig struct {
// Whether to add it to any of the page collections.
// Note that the page can always be found with .Site.GetPage.
// Valid values: never, always, local.
// Setting it to 'local' means they will be available via the local
// page collections, e.g. $section.Pages.
// Note: before 0.57.2 this was a bool, so we accept those too.
List string
// Whether to render it.
// Valid values: never, always, link.
// The value link means it will not be rendered, but it will get a RelPermalink/Permalink.
// Note that before 0.76.0 this was a bool, so we accept those too.
Render string
// Whether to publish its resources. These will still be published on demand,
// but enabling this can be useful if the originals (e.g. images) are
// never used.
PublishResources bool
}
BuildConfig holds configuration options about how to handle a Page in Hugo's build process.
func DecodeBuildConfig ¶
func DecodeBuildConfig(m any) (BuildConfig, error)
func (*BuildConfig) Disable ¶
func (b *BuildConfig) Disable()
Disable sets all options to their off value.
func (BuildConfig) IsZero ¶
func (b BuildConfig) IsZero() bool
type Dates ¶
func (Dates) IsAllDatesZero ¶
func (Dates) IsDateOrLastModAfter ¶
func (Dates) String ¶
func (*Dates) UpdateDateAndLastmodAndPublishDateIfAfter ¶
type DatesStrings ¶
type DatesStrings struct {
Date string `json:"date"`
Lastmod string `json:"lastMod"`
PublishDate string `json:"publishDate"`
ExpiryDate string `json:"expiryDate"`
}
type FrontMatterDescriptor ¶
type FrontMatterDescriptor struct {
// This is the Page's base filename (BaseFilename), e.g. page.md., or
// if page is a leaf bundle, the bundle folder name (ContentBaseName).
BaseFilename string
// The Page's path if the page is backed by a file, else its title.
PathOrTitle string
// The content file's mod time.
ModTime time.Time
// May be set from the author date in Git.
GitAuthorDate time.Time
PageConfigEarly *PageConfigEarly
// The below will be modified.
PageConfigLate *PageConfigLate
Location *time.Location // The Location to use to parse dates without time zone info.
}
FrontMatterDescriptor describes how to handle front matter for a given Page. It has pointers to values in the receiving page which gets updated.
type FrontMatterHandler ¶
type FrontMatterHandler struct {
// contains filtered or unexported fields
}
FrontMatterHandler maps front matter into Page fields and .Params. Note that we currently have only extracted the date logic.
func NewFrontmatterHandler ¶
func NewFrontmatterHandler(logger loggers.Logger, frontMatterConfig FrontmatterConfig) (FrontMatterHandler, error)
NewFrontmatterHandler creates a new FrontMatterHandler with the given logger and configuration. If no logger is provided, one will be created.
func (FrontMatterHandler) HandleDates ¶
func (f FrontMatterHandler) HandleDates(d *FrontMatterDescriptor) error
HandleDates updates all the dates given the current configuration and the supplied front matter params. Note that this requires all lower-case keys in the params map.
func (FrontMatterHandler) IsDateKey ¶
func (f FrontMatterHandler) IsDateKey(key string) bool
IsDateKey returns whether the given front matter key is considered a date by the current configuration.
type FrontMatterOnlyValues ¶
FrontMatterOnlyValues holds values that can only be set via front matter.
type FrontmatterConfig ¶
type FrontmatterConfig struct {
// Controls how the Date is set from front matter.
Date []string
// Controls how the Lastmod is set from front matter.
Lastmod []string
// Controls how the PublishDate is set from front matter.
PublishDate []string
// Controls how the ExpiryDate is set from front matter.
ExpiryDate []string
}
func DecodeFrontMatterConfig ¶
func DecodeFrontMatterConfig(cfg config.Provider) (FrontmatterConfig, error)
type PageConfigEarly ¶
type PageConfigEarly struct {
Kind string // The kind of page, e.g. "page", "section", "home" etc. This is usually derived from the content path.
Path string // The canonical path to the page, e.g. /sect/mypage. Note: Leading slash, no trailing slash, no extensions or language identifiers.
SourceEntryHash uint64 // The source entry hash for content adapters.
Sites sitesmatrix.Sites
Content Source // Content holds the content for this page.
Frontmatter maps.Params `mapstructure:"-" json:"-"` // The original front matter or content adapter map.
// Compiled values.
SitesMatrixAndComplements `mapstructure:"-" json:"-"`
IsFromContentAdapter bool `mapstructure:"-" json:"-"`
ContentMediaType media.Type `mapstructure:"-" json:"-"`
}
Page config that needs to be set early.
func (*PageConfigEarly) CompileEarly ¶
func (p *PageConfigEarly) CompileEarly(pi *paths.Path, cascades *page.PageMatcherParamsConfigs, conf config.AllProvider, fim *hugofs.FileMeta, sitesMatrixBase sitesmatrix.VectorIterator, sitesMatrixBaseOnly bool, ) error
func (*PageConfigEarly) CompileForPagesFromDataPre ¶
func (p *PageConfigEarly) CompileForPagesFromDataPre(basePath string, logger loggers.Logger, mediaTypes media.Types) error
func (*PageConfigEarly) Init ¶
func (p *PageConfigEarly) Init(pagesFromData bool) error
func (*PageConfigEarly) SetMetaPreFromMap ¶
func (pcfg *PageConfigEarly) SetMetaPreFromMap(ext string, frontmatter map[string]any, logger loggers.Logger, conf config.AllProvider) error
type PageConfigLate ¶
type PageConfigLate struct {
Dates Dates `json:"-"` // Dates holds the four core dates for this page.
DatesStrings
Params maps.Params // User defined params.
Title string // The title of the page.
LinkTitle string // The link title of the page.
Type string // The content type of the page.
Layout string // The layout to use for to render this page.
Weight int // The weight of the page, used in sorting if set to a non-zero value.
URL string // The URL to the rendered page, e.g. /sect/mypage.html.
Slug string // The slug for this page.
Description string // The description for this page.
Summary string // The summary for this page.
Draft bool // Whether or not the content is a draft.
Headless bool `json:"-"` // Whether or not the page should be rendered.
IsCJKLanguage bool // Whether or not the content is in a CJK language.
TranslationKey string // The translation key for this page.
Keywords []string // The keywords for this page.
Aliases []string // The aliases for this page.
Outputs []string // The output formats to render this page in. If not set, the site's configured output formats for this page kind will be used.
FrontMatterOnlyValues `mapstructure:"-" json:"-"`
Sitemap config.SitemapConfig
Build BuildConfig
Menus any // Can be a string, []string or map[string]any.
// Set only for pages created from data files.
ContentAdapterData map[string]any `mapstructure:"-" json:"-"`
// Compiled values.
ConfiguredOutputFormats output.Formats `mapstructure:"-" json:"-"`
}
PageConfig configures a Page, typically from front matter. Note that all the top level fields are reserved Hugo keywords. Any custom configuration needs to be set in the Params map.
func DefaultPageConfig ¶
func DefaultPageConfig() *PageConfigLate
func (*PageConfigLate) Compile ¶
func (p *PageConfigLate) Compile(e *PageConfigEarly, logger loggers.Logger, outputFormats output.Formats) error
Compile sets up the page configuration after all fields have been set.
func (*PageConfigLate) Init ¶
func (p *PageConfigLate) Init() error
type ResourceConfig ¶
type ResourceConfig struct {
Path string
Name string
Title string
Params maps.Params
Content Source
Sites sitesmatrix.Sites
// Compiled values.
ContentAdapterSourceEntryHash uint64 `mapstructure:"-" json:"-"`
PathInfo *paths.Path `mapstructure:"-" json:"-"`
ContentMediaType media.Type `mapstructure:"-" json:"-"`
SitesMatrixAndComplements `mapstructure:"-" json:"-"`
}
func (*ResourceConfig) Compile ¶
func (rc *ResourceConfig) Compile(basePath string, fim hugofs.FileMetaInfo, conf config.AllProvider, mediaTypes media.Types) error
func (*ResourceConfig) Validate ¶
func (rc *ResourceConfig) Validate() error
type SitesMatrixAndComplements ¶
type SitesMatrixAndComplements struct {
SitesMatrix sitesmatrix.VectorStore `mapstructure:"-" json:"-"`
SitesComplements sitesmatrix.VectorStore `mapstructure:"-" json:"-"`
}
SitesMatrixAndComplements holds a sites matrix and a sites complements configuration.
func (*SitesMatrixAndComplements) MatchLanguageCoarse ¶
func (p *SitesMatrixAndComplements) MatchLanguageCoarse(siteVector sitesmatrix.Vector) bool
MatchLanguageCoarse checks whether the language dimension matches either the sites matrix or the sites complements.
func (*SitesMatrixAndComplements) MatchRoleCoarse ¶
func (p *SitesMatrixAndComplements) MatchRoleCoarse(siteVector sitesmatrix.Vector) bool
MatchRoleCoarse checks whether the role dimension matches either the sites matrix or the sites complements.
func (*SitesMatrixAndComplements) MatchSiteVector ¶
func (p *SitesMatrixAndComplements) MatchSiteVector(siteVector sitesmatrix.Vector) bool
MatchSiteVector checks whether the site vector matches the sites matrix.
func (*SitesMatrixAndComplements) MatchVersionCoarse ¶
func (p *SitesMatrixAndComplements) MatchVersionCoarse(siteVector sitesmatrix.Vector) bool
MatchVersionCoarse checks whether the version dimension matches either the sites matrix or the sites complements.
type Source ¶
type Source struct {
// MediaType is the media type of the content.
MediaType string
// The markup used in Value. Only used in front matter.
Markup string
// The content.
Value any
}
func (Source) IsResourceValue ¶
func (Source) IsZero ¶
func (Source) ValueAsOpenReadSeekCloser ¶
func (s Source) ValueAsOpenReadSeekCloser() hugio.OpenReadSeekCloser
func (Source) ValueAsString ¶
Source Files ¶
page_frontmatter.go pagemeta.go
- Version
- v0.153.4 (latest)
- Published
- Dec 28, 2025
- Platform
- linux/amd64
- Imports
- 24 packages
- Last checked
- 4 months ago –
Tools for package owners.