Documentation ¶
Index ¶
- Constants
- Variables
- func AddFileInfoToError(err error, fi fs.FileMetaInfo, fs afero.Fs) error
- func CheckCascadePattern(m PageMatcher)
- func CreateShortcodePlaceholder(sid string, id uint64, ordinal int) string
- func DecodeCascadeConfig(in any) (map[PageMatcher]maps.Params, error)
- func GetKindAny(s string) string
- func GetKindMain(s string) string
- func GetParam(p maps.Params, key string, stringToLower bool) any
- func GetParamToLower(m maps.Params, key string) any
- func IsBranch(kind string) bool
- func IsDeprecatedAndReplacedWith(s string) string
- func MustUnwrapPage(in any) contenthub.Page
- func NewPageInfo(name, kind, dir string, sections []string, buf *bytes.Buffer) contenthub.PageInfo
- func NewZeroFile() contenthub.File
- func PosFromInput(filename string, input []byte, offset int) text.Position
- func PutPagePathBuilder(b *PagePathBuilder)
- func SortByDefault(pages contenthub.Pages)
- func SortByLanguage(pages contenthub.Pages)
- func SortByWeight(pages contenthub.Pages)
- func UniqueStringsReuse(s []string) []string
- type BundleType
- type Cascade
- type ContentSummary
- type ConverterProvider
- type ConverterRegistry
- type File
- func (fi *File) BaseFileName() string
- func (fi *File) ContentBaseName() string
- func (fi *File) Dir() string
- func (fi *File) Ext() string
- func (fi *File) FileInfo() fs.FileMetaInfo
- func (fi *File) Filename() string
- func (fi *File) IsZero() bool
- func (fi *File) LogicalName() string
- func (fi *File) Open() (io.ReadSeekCloser, error)
- func (fi *File) Opener() io.OpenReadSeekCloser
- func (fi *File) PageFile() contenthub.File
- func (fi *File) Path() string
- func (fi *File) Paths() *paths.Path
- func (fi *File) RelPath() string
- func (fi *File) Section() string
- func (fi *File) ShiftToResource()
- func (fi *File) String() string
- func (fi *File) TranslationBaseName() string
- func (fi *File) UniqueID() string
- type FileManager
- type FrontMatter
- type FrontMatterParser
- type Identity
- type ItemHandler
- type IterHandler
- type LayoutDescriptor
- type LayoutHandler
- type LayoutLooker
- type PageContentReplacement
- type PageMatcher
- type PageMatcherParamsConfig
- type PagePathBuilder
- func (p *PagePathBuilder) Add(el ...string)
- func (p *PagePathBuilder) ConcatLast(s string)
- func (p *PagePathBuilder) IsHtmlIndex() bool
- func (p *PagePathBuilder) Last() string
- func (p *PagePathBuilder) Link() string
- func (p *PagePathBuilder) LinkDir() string
- func (p *PagePathBuilder) Path(upperOffset int) string
- func (p *PagePathBuilder) PathDir() string
- func (p *PagePathBuilder) PathDirBase() string
- func (p *PagePathBuilder) PathFile() string
- func (p *PagePathBuilder) Prepend(el ...string)
- func (p *PagePathBuilder) Sanitize()
- type PageWrapper
- type Shortcode
- type ShortcodeParser
- type ShortcodeRenderFunc
- type ShortcodeRenderer
- type SourceHandlers
- type SourceParseInfo
- type Target
- type TocConfig
- type WhatChanged
Constants ¶
const ( KindPage = "page" KindHome = "home" KindSection = "section" // Note that before Hugo 0.73 these were confusingly named // taxonomy (now: term) // taxonomyTerm (now: taxonomy) KindTaxonomy = "taxonomy" KindTerm = "term" // The following are (currently) temporary nodes, // i.e. nodes we create just to render in isolation. KindRSS = "rss" KindSitemap = "sitemap" KindSitemapIndex = "sitemapindex" KindRobotsTXT = "robotstxt" KindStatus404 = "404" )
const ShortcodePlaceholderPrefix = "HAHAHUGOSHORTCODE"
Variables ¶
var ( // This is all the kinds we can expect to find in .Site.Pages. AllKindsInPages []string // This is all the kinds, including the temporary ones. AllKinds []string )
var DefaultTocConfig = TocConfig{ StartLevel: 2, EndLevel: 3, Ordered: false, }
DefaultTocConfig is the default ToC configuration.
var MDProvider contenthub.ProviderProvider = provide{}
MDProvider is the package entry point.
var (
NilPage *nopPage
)
var TocShortcodePlaceholder = CreateShortcodePlaceholder("TOC", 0, 0)
var ZeroShortcode = prerenderedShortcode{}
Functions ¶
func AddFileInfoToError ¶
AddFileInfoToError adds file info to the given error.
func CheckCascadePattern ¶
func CheckCascadePattern(m PageMatcher)
func DecodeCascadeConfig ¶
func DecodeCascadeConfig(in any) (map[PageMatcher]maps.Params, error)
func GetKindAny ¶
GetKindAny gets the page kind given a string, empty if not found.
func GetKindMain ¶
GetKindMain gets the page kind given a string, empty if not found. Note that this will not return any temporary kinds (e.g. robotstxt).
func IsDeprecatedAndReplacedWith ¶
IsDeprecatedAndReplacedWith returns the new kind if the given kind is deprecated.
func MustUnwrapPage ¶
func MustUnwrapPage(in any) contenthub.Page
func NewPageInfo ¶
func NewZeroFile ¶
func NewZeroFile() contenthub.File
func PutPagePathBuilder ¶
func PutPagePathBuilder(b *PagePathBuilder)
func SortByDefault ¶
func SortByDefault(pages contenthub.Pages)
SortByDefault sorts pages by the default sort.
func SortByLanguage ¶
func SortByLanguage(pages contenthub.Pages)
func SortByWeight ¶ added in v0.0.5
func SortByWeight(pages contenthub.Pages)
SortByWeight sorts pages by weight.
func UniqueStringsReuse ¶
UniqueStringsReuse returns a slice with any duplicates removed. It will modify the input slice.
Types ¶
type BundleType ¶
type BundleType int
const ( // BundleTypeFile A generic resource, e.g. a JSON file. BundleTypeFile BundleType = iota // BundleTypeContentResource All below are content files. // A resource of a content type with front matter. // A single file but not leaf BundleTypeContentResource // BundleTypeContentSingle E.g. /blog/my-post.md BundleTypeContentSingle // BundleTypeLeaf Leaf bundles, e.g. /blog/my-post/index.md BundleTypeLeaf // BundleTypeBranch Branch bundles, e.g. /blog/_index.md BundleTypeBranch )
func (BundleType) IsBranchBundle ¶
func (b BundleType) IsBranchBundle() bool
func (BundleType) IsBundle ¶
func (b BundleType) IsBundle() bool
func (BundleType) IsContent ¶
func (b BundleType) IsContent() bool
IsContent returns true if the path is a content file (e.g. mypost.md). Note that this will also return true for content files in a bundle.
func (BundleType) IsContentResource ¶
func (b BundleType) IsContentResource() bool
func (BundleType) IsLeafBundle ¶
func (b BundleType) IsLeafBundle() bool
type ContentSummary ¶
type ContentSummary struct { Content template.HTML Summary template.HTML SummaryTruncated bool TableOfContentsHTML template.HTML }
func NewEmptyContentSummary ¶
func NewEmptyContentSummary() ContentSummary
type ConverterProvider ¶
type ConverterProvider struct {
// contains filtered or unexported fields
}
func (ConverterProvider) Name ¶
func (n ConverterProvider) Name() string
func (ConverterProvider) New ¶
func (n ConverterProvider) New(ctx markdown.DocumentContext) (contenthub.Converter, error)
type ConverterRegistry ¶
type ConverterRegistry struct { // Maps name (md, markdown, goldmark etc.) to a converter provider. // Note that this is also used for aliasing, so the same converter // may be registered multiple times. // All names are lower case. Converters map[string]contenthub.ConverterProvider }
func (*ConverterRegistry) Get ¶
func (r *ConverterRegistry) Get(name string) contenthub.ConverterProvider
type File ¶
type File struct { fs.FileMetaInfo BundleType // contains filtered or unexported fields }
File describes a source file.
func NewFileInfo ¶
func NewFileInfo(fi fs.FileMetaInfo) *File
func (*File) BaseFileName ¶
BaseFileName returns a file's name without extension (e.g. "page.sv").
func (*File) ContentBaseName ¶
ContentBaseName is a either TranslationBaseName or name of containing folder if file is a bundle.
func (*File) Dir ¶
Dir gets the name of the directory that contains this file. The directory is relative to the content root.
func (*File) FileInfo ¶
func (fi *File) FileInfo() fs.FileMetaInfo
FileInfo returns a file's underlying os.FileInfo.
func (*File) LogicalName ¶
LogicalName returns a file's name and extension (e.g. "page.sv.md").
func (*File) Opener ¶
func (fi *File) Opener() io.OpenReadSeekCloser
func (*File) PageFile ¶
func (fi *File) PageFile() contenthub.File
func (*File) RelPath ¶
RelPath Paths gets the relative path including file name and extension. The directory is relative to the content root.
func (*File) ShiftToResource ¶
func (fi *File) ShiftToResource()
func (*File) TranslationBaseName ¶
TranslationBaseName returns a file's translation base name without the language segment (e.g. "page").
type FileManager ¶
type FileManager struct {
// contains filtered or unexported fields
}
func NewFsManager ¶
func NewFsManager(fis []fs.FileMetaInfo) *FileManager
func (*FileManager) GetLeaf ¶
func (f *FileManager) GetLeaf() *File
type FrontMatter ¶
type FrontMatterParser ¶
type FrontMatterParser struct { Params maps.Params LangSvc contenthub.LangService TaxonomySvc contenthub.TaxonomyService }
func (*FrontMatterParser) Parse ¶
func (b *FrontMatterParser) Parse() (*FrontMatter, error)
type Identity ¶
func (Identity) IdentifierBase ¶
func (Identity) PageIdentity ¶
func (i Identity) PageIdentity() contenthub.PageIdentity
func (Identity) PageLanguage ¶
func (Identity) PageLanguageIndex ¶
type ItemHandler ¶
type ItemHandler func(item pageparser.Item) error
type IterHandler ¶
type IterHandler func(item pageparser.Item, iter *pageparser.Iterator) error
type LayoutDescriptor ¶
type LayoutDescriptor struct { Type string Section string // E.g. "page", but also used for the _markup render kinds, e.g. "render-images". Kind string // Comma-separated list of kind variants, e.g. "go,json" as variants which would find "render-codeblock-go.html" KindVariants string Lang string Layout string // LayoutOverride indicates what we should only look for the above layout. LayoutOverride bool RenderingHook bool Baseof bool FormatName string Extension string }
LayoutDescriptor describes how a layout should be chosen. This is typically built from a Page.
type LayoutHandler ¶
type LayoutHandler struct {
// contains filtered or unexported fields
}
LayoutHandler calculates the layout template to use to render a given output type.
func NewLayoutHandler ¶
func NewLayoutHandler() *LayoutHandler
NewLayoutHandler creates a new LayoutHandler.
func (*LayoutHandler) For ¶
func (l *LayoutHandler) For(d LayoutDescriptor) ([]string, error)
For returns a layout for the given LayoutDescriptor and options. Layouts are rendered and cached internally.
type LayoutLooker ¶
type LayoutLooker struct {
// contains filtered or unexported fields
}
func NewLayoutLooker ¶
func NewLayoutLooker(names []string, bnames []string) *LayoutLooker
func (*LayoutLooker) BaseNames ¶
func (l *LayoutLooker) BaseNames() []string
func (*LayoutLooker) Names ¶
func (l *LayoutLooker) Names() []string
type PageContentReplacement ¶
type PageContentReplacement struct { Val []byte Source pageparser.Item }
type PageMatcher ¶
type PageMatcher struct { // A Glob pattern matching the content path below /content. // Expects Unix-styled slashes. // Note that this is the virtual path, so it starts at the mount root // with a leading "/". Path string // A Glob pattern matching the Page's Kind(s), e.g. "{home,section}" Kind string // A Glob pattern matching the Page's language, e.g. "{en,sv}". Lang string // A Glob pattern matching the Page's Environment, e.g. "{production,development}". Environment string }
A PageMatcher can be used to match a Page with Glob patterns. Note that the pattern matching is case insensitive.
func (PageMatcher) Matches ¶
func (m PageMatcher) Matches(p contenthub.Page) bool
Matches returns whether p matches this matcher.
type PageMatcherParamsConfig ¶
type PageMatcherParamsConfig struct { // Apply Params to all Pages matching Target. Params maps.Params Target PageMatcher }
type PagePathBuilder ¶
type PagePathBuilder struct { // Builder state. IsUgly bool BaseNameSameAsType bool // Remove it, only sitemap has same basename from both output format and descriptor NoSubResources bool FullSuffix string // File suffix including any ".". PrefixPath string LinkUpperOffset int // contains filtered or unexported fields }
PagePathBuilder When adding state here, remember to update putPagePathBuilder.
func GetPagePathBuilder ¶
func GetPagePathBuilder(format output.Format) *PagePathBuilder
func (*PagePathBuilder) Add ¶
func (p *PagePathBuilder) Add(el ...string)
func (*PagePathBuilder) ConcatLast ¶
func (p *PagePathBuilder) ConcatLast(s string)
func (*PagePathBuilder) IsHtmlIndex ¶
func (p *PagePathBuilder) IsHtmlIndex() bool
func (*PagePathBuilder) Last ¶
func (p *PagePathBuilder) Last() string
func (*PagePathBuilder) Link ¶
func (p *PagePathBuilder) Link() string
func (*PagePathBuilder) LinkDir ¶
func (p *PagePathBuilder) LinkDir() string
func (*PagePathBuilder) Path ¶
func (p *PagePathBuilder) Path(upperOffset int) string
func (*PagePathBuilder) PathDir ¶
func (p *PagePathBuilder) PathDir() string
func (*PagePathBuilder) PathDirBase ¶
func (p *PagePathBuilder) PathDirBase() string
func (*PagePathBuilder) PathFile ¶
func (p *PagePathBuilder) PathFile() string
func (*PagePathBuilder) Prepend ¶
func (p *PagePathBuilder) Prepend(el ...string)
func (*PagePathBuilder) Sanitize ¶
func (p *PagePathBuilder) Sanitize()
type PageWrapper ¶
type PageWrapper interface {
// contains filtered or unexported methods
}
type Shortcode ¶
type Shortcode struct { Name string Ordinal int Indentation string // indentation from source. Inner []any // string or nested shortcode IsInline bool // inline shortcode. Any inner will be a Go template. // If set, the rendered shortcode is sent as part of the surrounding content // to Goldmark and similar. // Before Hug0 0.55 we didn't send any shortcode output to the markup // renderer, and this flag told Hugo to process the {{ .Inner }} content // separately. // The old behavior can be had by starting your shortcode template with: // {{ $_hugo_config := `{ "version": 1 }`}} DoMarkup bool IsClosing bool // whether a closing tag was provided Info template.Info // One of the output formats (arbitrary) Templs []template.Preparer // All output formats Params any // map or array Pos int // the position in bytes in the source file Length int // the length in bytes in the source file // the placeholder in the source when passed to Goldmark etc. // This also identifies the rendered shortcode. Placeholder string }
func (Shortcode) InsertPlaceholder ¶
func (Shortcode) NeedsInner ¶
type ShortcodeParser ¶
type ShortcodeParser struct {
// contains filtered or unexported fields
}
func NewShortcodeParser ¶
func NewShortcodeParser(source []byte, pid uint64, tmplSvc contenthub.Template) *ShortcodeParser
func (*ShortcodeParser) ParseItem ¶
func (s *ShortcodeParser) ParseItem(it pageparser.Item, pt *pageparser.Iterator) (*Shortcode, error)
type ShortcodeRenderFunc ¶
func (ShortcodeRenderFunc) RenderShortcode ¶
func (ShortcodeRenderFunc) RenderShortcodeString ¶
type ShortcodeRenderer ¶
type ShortcodeRenderer interface { RenderShortcode(context.Context) ([]byte, bool, error) RenderShortcodeString(context.Context) (string, bool, error) }
ShortcodeRenderer is typically used to delay rendering of inner shortcodes marked with placeholders in the content.
func NewPrerenderedShortcode ¶
func NewPrerenderedShortcode(s string, hasVariants bool) ShortcodeRenderer
type SourceHandlers ¶
type SourceHandlers interface { FrontMatterHandler() ItemHandler SummaryHandler() IterHandler BytesHandler() ItemHandler ShortcodeHandler() IterHandler }
type SourceParseInfo ¶
type SourceParseInfo struct { Source []byte // Items from the page parser. // These maps directly to the source ItemsStep1 pageparser.Items Handlers SourceHandlers // contains filtered or unexported fields }
func NewSourceParseInfo ¶
func NewSourceParseInfo(source []byte, handlers SourceHandlers) (*SourceParseInfo, error)
func (*SourceParseInfo) Handle ¶
func (s *SourceParseInfo) Handle() error
func (*SourceParseInfo) IsEmpty ¶
func (s *SourceParseInfo) IsEmpty() bool
func (*SourceParseInfo) Parse ¶
func (s *SourceParseInfo) Parse() error
type Target ¶
type Target struct { Prefix string // Where to store the file on disk relative to the publish dir. OS slashes. FilePath string // The directory to write sub-resources of the above. SubResourceBaseTarget string Format output.Format }
func (*Target) TargetFilePath ¶
func (*Target) TargetFormat ¶
func (*Target) TargetPrefix ¶
func (*Target) TargetSubResourceDir ¶
type TocConfig ¶
type TocConfig struct { // Heading start level to include in the table of contents, starting // at h1 (inclusive). // <docsmeta>{ "identifiers": ["h1"] }</docsmeta> StartLevel int // Heading end level, inclusive, to include in the table of contents. // Default is 3, a value of -1 will include everything. EndLevel int // Whether to produce a ordered list or not. Ordered bool }
type WhatChanged ¶
type WhatChanged struct { IdentitySet identity.Identities // contains filtered or unexported fields }
func (*WhatChanged) Add ¶
func (w *WhatChanged) Add(ids ...identity.Identity)
func (*WhatChanged) Changes ¶
func (w *WhatChanged) Changes() []identity.Identity
Source Files ¶
- bundle.go
- cascade.go
- changes.go
- content.go
- contentreplacement.go
- converter.go
- fileerr.go
- fileinfo.go
- frontmatter.go
- fsmanager.go
- identity.go
- kind.go
- layout.go
- looker.go
- markdown.go
- matcher.go
- pageinfo.go
- pagenop.go
- parseinfo.go
- scparser.go
- shortcode.go
- sort.go
- target.go
- unwrap.go
- zero_file.autogen.go