Documentation ¶
Index ¶
- Constants
- Variables
- type Cache
- type Content
- func (c *Content) AddItems(item pageparser.Item)
- func (c *Content) AddReplacement(val []byte, source pageparser.Item)
- func (c *Content) AddShortcode(s *valueobject.Shortcode)
- func (c *Content) PureContent() string
- func (c *Content) RawContent() string
- func (c *Content) SetSummaryDivider()
- func (c *Content) SetSummaryTruncated()
- type ContentHub
- func (ch *ContentHub) CollectPages(exec contenthub.Template) error
- func (ch *ContentHub) GetPageFromPath(path string) (contenthub.Page, error)
- func (ch *ContentHub) GetPageSources(page contenthub.Page) ([]contenthub.PageSource, error)
- func (ch *ContentHub) GlobalPages() contenthub.Pages
- func (ch *ContentHub) ProcessPages(exec contenthub.Template) error
- func (ch *ContentHub) RenderString(ctx context.Context, args ...any) (goTmpl.HTML, error)
- func (ch *ContentHub) WalkPages(langIndex int, walker contenthub.WalkFunc) error
- func (ch *ContentHub) WalkTaxonomies(langIndex int, walker contenthub.WalkTaxonomyFunc) error
- type ContentProvider
- type ContentSpec
- type Layout
- type Meta
- type Output
- type Page
- func (p *Page) AllTranslations() contenthub.Pages
- func (p *Page) Eq(other contenthub.Page) bool
- func (p *Page) IsAncestor(other contenthub.Page) bool
- func (p *Page) IsBundled() bool
- func (p *Page) IsHome() bool
- func (p *Page) IsPage() bool
- func (p *Page) IsSection() bool
- func (p *Page) Kind() string
- func (p *Page) Layouts() []string
- func (p *Page) PageOutputs() ([]contenthub.PageOutput, error)
- func (p *Page) Pages(langIndex int) contenthub.Pages
- func (p *Page) Title() string
- func (p *Page) Translations() contenthub.Pages
- type PageBuilder
- func (b *PageBuilder) Build() (contenthub.Page, error)
- func (b *PageBuilder) BytesHandler() valueobject.ItemHandler
- func (b *PageBuilder) FrontMatterHandler() valueobject.ItemHandler
- func (b *PageBuilder) KindBuild() (contenthub.Page, error)
- func (b *PageBuilder) ShortcodeHandler() valueobject.IterHandler
- func (b *PageBuilder) SummaryHandler() valueobject.IterHandler
- func (b *PageBuilder) WithSource(source *Source) *PageBuilder
- type PageMap
- type PageTrees
- type PageTreesNode
- type Section
- type ShortcodeWithPage
- func (scp *ShortcodeWithPage) Get(key any) any
- func (scp *ShortcodeWithPage) InnerDeindent() template.HTML
- func (scp *ShortcodeWithPage) Position() text.Position
- func (scp *ShortcodeWithPage) Ref(args map[string]any) (string, error)
- func (scp *ShortcodeWithPage) RelRef(args map[string]any) (string, error)
- func (scp *ShortcodeWithPage) Scratch() *maps.Scratch
- func (scp *ShortcodeWithPage) Unwrapv() any
- type Source
- type SourceShifter
- func (s *SourceShifter) Delete(n *PageTreesNode, dimension doctree.Dimension) (bool, bool)
- func (s *SourceShifter) ForEachInDimension(n *PageTreesNode, d int, f func(*PageTreesNode) bool)
- func (s *SourceShifter) Insert(old, new *PageTreesNode) *PageTreesNode
- func (s *SourceShifter) InsertInto(old, new *PageTreesNode, dimension doctree.Dimension) *PageTreesNode
- func (s *SourceShifter) Shift(n *PageTreesNode, dimension doctree.Dimension, exact bool) (*PageTreesNode, bool, doctree.DimensionFlag)
- type Standalone
- type Taxonomy
- type TaxonomyPage
- type Term
- type TermPage
- type Title
- type TitleStyle
- type WeightedTermTreeNode
Constants ¶
const ( LayoutSection = "section.html" LayoutList = "list.html" LayoutIndex = "index.html" InternalFolder = "_internal" DefaultFolder = "_default" DefaultIndex = "_default/index.html" DefaultList = DefaultFolder + "/" + LayoutList DefaultPage = "_default/single.html" DefaultSection = DefaultFolder + "/" + LayoutSection DefaultTaxonomy = "_default/taxonomy.html" DefaultTerm = "_default/term.html" DefaultBaseof = "_default/baseof.html" TaxonomyTaxonomy = "taxonomy/taxonomy.html" TaxonomyList = "taxonomy" + "/" + LayoutList TermTerm = "term/term.html" TermList = "taxonomy" + "/" + LayoutList Sitemap = "sitemap.xml" DefaultSitemap = DefaultFolder + "/" + "sitemap.xml" InternalDefaultSitemap = InternalFolder + "/" + DefaultFolder + "/" + "sitemap.xml" )
const ( Never = "never" Always = "always" ListLocally = "local" Link = "link" )
const ( StandalonePage404Base = "404" StandalonePageSitemapBase = "_sitemap" )
const PageHomeBase = "/"
Variables ¶
var (
InternalSummaryDividerPre = []byte("\n\n" + internalSummaryDividerBase + "\n\n")
)
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct { CachePages1 *dynacache.Partition[string, contenthub.Pages] CachePages2 *dynacache.Partition[string, contenthub.Pages] // Cache for content sources. CacheContentSource *dynacache.Partition[string, *stale.Value[[]byte]] CachePageSource *dynacache.Partition[string, contenthub.PageSource] CachePageSources *dynacache.Partition[string, []contenthub.PageSource] CacheContentRendered *dynacache.Partition[string, *stale.Value[valueobject.ContentSummary]] CacheContentToRender *dynacache.Partition[string, *stale.Value[[]byte]] CacheContentShortcodes *dynacache.Partition[string, *stale.Value[map[string]valueobject.ShortcodeRenderer]] }
func (*Cache) GetOrCreateResource ¶
func (c *Cache) GetOrCreateResource(key string, f func() (contenthub.PageSource, error)) (contenthub.PageSource, error)
func (*Cache) GetOrCreateResources ¶
func (c *Cache) GetOrCreateResources(key string, f func() ([]contenthub.PageSource, error)) ([]contenthub.PageSource, error)
type Content ¶
type Content struct {
// contains filtered or unexported fields
}
func NewContent ¶
func (*Content) AddItems ¶
func (c *Content) AddItems(item pageparser.Item)
func (*Content) AddReplacement ¶
func (c *Content) AddReplacement(val []byte, source pageparser.Item)
func (*Content) AddShortcode ¶
func (c *Content) AddShortcode(s *valueobject.Shortcode)
func (*Content) PureContent ¶
func (*Content) RawContent ¶
func (*Content) SetSummaryDivider ¶
func (c *Content) SetSummaryDivider()
func (*Content) SetSummaryTruncated ¶
func (c *Content) SetSummaryTruncated()
type ContentHub ¶
type ContentHub struct { Fs contenthub.FsService // ExecTemplate handling. TemplateExecutor contenthub.Template *Cache *PageMap *Title Log loggers.Logger `json:"-"` // contains filtered or unexported fields }
func (*ContentHub) CollectPages ¶
func (ch *ContentHub) CollectPages(exec contenthub.Template) error
func (*ContentHub) GetPageFromPath ¶
func (ch *ContentHub) GetPageFromPath(path string) (contenthub.Page, error)
func (*ContentHub) GetPageSources ¶
func (ch *ContentHub) GetPageSources(page contenthub.Page) ([]contenthub.PageSource, error)
func (*ContentHub) GlobalPages ¶
func (ch *ContentHub) GlobalPages() contenthub.Pages
func (*ContentHub) ProcessPages ¶
func (ch *ContentHub) ProcessPages(exec contenthub.Template) error
func (*ContentHub) RenderString ¶
func (*ContentHub) WalkPages ¶
func (ch *ContentHub) WalkPages(langIndex int, walker contenthub.WalkFunc) error
func (*ContentHub) WalkTaxonomies ¶
func (ch *ContentHub) WalkTaxonomies(langIndex int, walker contenthub.WalkTaxonomyFunc) error
type ContentProvider ¶
type ContentProvider struct {
// contains filtered or unexported fields
}
func (*ContentProvider) Content ¶
func (c *ContentProvider) Content() (any, error)
func (*ContentProvider) ContentSummary ¶
func (c *ContentProvider) ContentSummary() (valueobject.ContentSummary, error)
func (*ContentProvider) Summary ¶
func (c *ContentProvider) Summary() goTemplate.HTML
func (*ContentProvider) TableOfContents ¶
func (c *ContentProvider) TableOfContents() goTemplate.HTML
type ContentSpec ¶
type ContentSpec struct {
Converters contenthub.ConverterRegistry
}
func (*ContentSpec) GetContentConvertProvider ¶
func (c *ContentSpec) GetContentConvertProvider(name string) contenthub.ConverterProvider
func (*ContentSpec) ResolveMarkup ¶
func (c *ContentSpec) ResolveMarkup(in string) string
type Output ¶
type Output struct {
// contains filtered or unexported fields
}
func (*Output) Build ¶
func (o *Output) Build(convertProvider *ContentSpec, templateSvc contenthub.Template, mediaSvc contenthub.MediaService) error
func (*Output) Outputs ¶
func (o *Output) Outputs(p *Page) ([]contenthub.PageOutput, error)
type Page ¶
type Page struct { *Source *Content *Meta *Layout *Output // contains filtered or unexported fields }
func (*Page) AllTranslations ¶
func (p *Page) AllTranslations() contenthub.Pages
AllTranslations returns all translations, including the current Page.
func (*Page) IsAncestor ¶
func (p *Page) IsAncestor(other contenthub.Page) bool
func (*Page) PageOutputs ¶
func (p *Page) PageOutputs() ([]contenthub.PageOutput, error)
func (*Page) Translations ¶
func (p *Page) Translations() contenthub.Pages
type PageBuilder ¶
type PageBuilder struct { LangSvc contenthub.LangService TaxonomySvc contenthub.TaxonomyService TemplateSvc contenthub.Template MediaSvc contenthub.MediaService PageMapper *PageMap Taxonomy *Taxonomy Term *Term Section *Section Standalone *Standalone ConvertProvider *ContentSpec Log loggers.Logger // contains filtered or unexported fields }
func (*PageBuilder) Build ¶
func (b *PageBuilder) Build() (contenthub.Page, error)
func (*PageBuilder) BytesHandler ¶
func (b *PageBuilder) BytesHandler() valueobject.ItemHandler
func (*PageBuilder) FrontMatterHandler ¶
func (b *PageBuilder) FrontMatterHandler() valueobject.ItemHandler
func (*PageBuilder) KindBuild ¶
func (b *PageBuilder) KindBuild() (contenthub.Page, error)
func (*PageBuilder) ShortcodeHandler ¶
func (b *PageBuilder) ShortcodeHandler() valueobject.IterHandler
func (*PageBuilder) SummaryHandler ¶
func (b *PageBuilder) SummaryHandler() valueobject.IterHandler
func (*PageBuilder) WithSource ¶
func (b *PageBuilder) WithSource(source *Source) *PageBuilder
type PageMap ¶
type PageMap struct { // Main storage for all pages. *PageTrees Cache *Cache PageBuilder *PageBuilder Log loggers.Logger }
func (*PageMap) InsertResourceNode ¶
func (m *PageMap) InsertResourceNode(key string, node *PageTreesNode)
type PageTrees ¶
type PageTrees struct { // This tree contains all Pages. // This include regular pages, sections, taxonomies and so on. // Note that all of these trees share the same key structure, // so you can take a leaf Page key and do a prefix search // with key + "/" to get all of its resources. TreePages *doctree.NodeShiftTree[*PageTreesNode] // This tree contains Resources bundled in pages. TreeResources *doctree.NodeShiftTree[*PageTreesNode] // All pages and resources. TreePagesResources doctree.WalkableTrees[*PageTreesNode] // This tree contains all taxonomy entries, e.g "/tags/blue/page1" TreeTaxonomyEntries *doctree.TreeShiftTree[*WeightedTermTreeNode] // A slice of the resource trees. ResourceTrees doctree.MutableTrees }
PageTrees holds pages and resources in a tree structure for all sites/languages. Each site gets its own tree set via the Shape method.
func (*PageTrees) CreateMutableTrees ¶
func (t *PageTrees) CreateMutableTrees()
type PageTreesNode ¶
type PageTreesNode struct {
// contains filtered or unexported fields
}
type Section ¶
type Section struct { FsSvc contenthub.FsService Cache *Cache // contains filtered or unexported fields }
func (*Section) Assemble ¶
func (s *Section) Assemble(pages *doctree.NodeShiftTree[*PageTreesNode], pb *PageBuilder) error
func (*Section) CreateHome ¶
func (s *Section) CreateHome(pb *PageBuilder) error
type ShortcodeWithPage ¶
type ShortcodeWithPage struct { Params any Inner template.HTML Page contenthub.Page // TODO, check if this is needed Parent *ShortcodeWithPage Name string IsNamedParams bool // Zero-based ordinal in relation to its parent. If the parent is the page itself, // this ordinal will represent the position of this shortcode in the page content. Ordinal int // contains filtered or unexported fields }
ShortcodeWithPage is the "." context in a shortcode template.
func (*ShortcodeWithPage) Get ¶
func (scp *ShortcodeWithPage) Get(key any) any
Get is a convenience method to look up shortcode parameters by its key.
func (*ShortcodeWithPage) InnerDeindent ¶
func (scp *ShortcodeWithPage) InnerDeindent() template.HTML
InnerDeindent returns the (potentially de-indented) inner content of the shortcode.
func (*ShortcodeWithPage) Position ¶
func (scp *ShortcodeWithPage) Position() text.Position
Position returns this shortcode's detailed position. Note that this information may be expensive to calculate, so only use this in error situations.
func (*ShortcodeWithPage) Ref ¶
func (scp *ShortcodeWithPage) Ref(args map[string]any) (string, error)
Ref is a shortcut to the Ref method on Page. It passes itself as a context to get better error messages.
func (*ShortcodeWithPage) RelRef ¶
func (scp *ShortcodeWithPage) RelRef(args map[string]any) (string, error)
RelRef is a shortcut to the RelRef method on Page. It passes itself as a context to get better error messages.
func (*ShortcodeWithPage) Scratch ¶
func (scp *ShortcodeWithPage) Scratch() *maps.Scratch
Scratch returns a scratch-pad scoped for this shortcode. This can be used as a temporary storage for variables, counters etc.
func (*ShortcodeWithPage) Unwrapv ¶
func (scp *ShortcodeWithPage) Unwrapv() any
For internal use only.
type Source ¶
type Source struct { *valueobject.Identity *valueobject.File stale.Staler // contains filtered or unexported fields }
type SourceShifter ¶
type SourceShifter struct{}
func (*SourceShifter) Delete ¶
func (s *SourceShifter) Delete(n *PageTreesNode, dimension doctree.Dimension) (bool, bool)
func (*SourceShifter) ForEachInDimension ¶
func (s *SourceShifter) ForEachInDimension(n *PageTreesNode, d int, f func(*PageTreesNode) bool)
func (*SourceShifter) Insert ¶
func (s *SourceShifter) Insert(old, new *PageTreesNode) *PageTreesNode
func (*SourceShifter) InsertInto ¶
func (s *SourceShifter) InsertInto(old, new *PageTreesNode, dimension doctree.Dimension) *PageTreesNode
func (*SourceShifter) Shift ¶
func (s *SourceShifter) Shift(n *PageTreesNode, dimension doctree.Dimension, exact bool) (*PageTreesNode, bool, doctree.DimensionFlag)
type Standalone ¶
type Standalone struct { FsSvc contenthub.FsService Cache *Cache }
func (*Standalone) Assemble ¶
func (s *Standalone) Assemble(pages *doctree.NodeShiftTree[*PageTreesNode], pb *PageBuilder) error
type Taxonomy ¶
type Taxonomy struct { Views []contenthub.Taxonomy FsSvc contenthub.FsService Cache *Cache }
func (*Taxonomy) Assemble ¶
func (t *Taxonomy) Assemble(pages *doctree.NodeShiftTree[*PageTreesNode], pb *PageBuilder) error
func (*Taxonomy) PluralTreeKey ¶
type TaxonomyPage ¶
type TaxonomyPage struct { *Page // contains filtered or unexported fields }
type Term ¶
type Term struct { Terms map[string][]string FsSvc contenthub.FsService Cache *Cache }
func (*Term) Assemble ¶
func (t *Term) Assemble(pages *doctree.NodeShiftTree[*PageTreesNode], entries *doctree.TreeShiftTree[*WeightedTermTreeNode], pb *PageBuilder) error
type TermPage ¶
type TermPage struct { *TaxonomyPage // contains filtered or unexported fields }
type WeightedTermTreeNode ¶
type WeightedTermTreeNode struct { *PageTreesNode // contains filtered or unexported fields }
Source Files ¶
- cache.go
- contenthub.go
- contentspec.go
- layout.go
- page.go
- pagebuilder.go
- pagecollector.go
- pagecontent.go
- pagecontentprovider.go
- pagecontext.go
- pagefields.go
- pagemap.go
- pagemeta.go
- pageoutput.go
- pagequery.go
- pagesource.go
- pagesourceshifter.go
- pagetrees.go
- section.go
- shortcodepage.go
- standalone.go
- taxonomy.go
- term.go
- title.go
- walk.go