generator

package
v0.0.0-...-efe9689 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2024 License: BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_TEMPLATE = "default.html"

Variables

View Source
var LinkEndRegexp = regexp.MustCompile(`></link>`)

Functions

func PaginateTransform

func PaginateTransform[S ~[]E, E any, F any](collection S, perPage int, transformer func(input E) F) [][]F

Types

type ContentHierarchy

type ContentHierarchy struct {
	Pages        map[string]*ContentNode
	Taxonomies   map[string]TermMap
	TaxonomyPage map[string]*content.WebPage

	StaticFiles map[string]string
	// contains filtered or unexported fields
}

func NewPageHierarchy

func NewPageHierarchy(verbose bool) *ContentHierarchy

func (*ContentHierarchy) AddPage

func (ph *ContentHierarchy) AddPage(page *content.WebPage)

func (*ContentHierarchy) AddStaticFile

func (ph *ContentHierarchy) AddStaticFile(relPath, fullPath string)

func (*ContentHierarchy) Clear

func (ph *ContentHierarchy) Clear(args ...interface{})

func (*ContentHierarchy) GatherContent

func (ph *ContentHierarchy) GatherContent(contentDir string) error

func (*ContentHierarchy) GetChildren

func (ph *ContentHierarchy) GetChildren(page content.WebPage) []*content.WebPage

func (*ContentHierarchy) GetNextPage

func (ph *ContentHierarchy) GetNextPage(parent *content.WebPage, child *content.WebPage) *content.WebPage

func (*ContentHierarchy) GetPage

func (ph *ContentHierarchy) GetPage(path string) *content.WebPage

func (*ContentHierarchy) GetParent

func (ph *ContentHierarchy) GetParent(page content.WebPage) *content.WebPage

func (*ContentHierarchy) GetPrevPage

func (ph *ContentHierarchy) GetPrevPage(parent *content.WebPage, child *content.WebPage) *content.WebPage

func (*ContentHierarchy) GetTaxonomyPage

func (ph *ContentHierarchy) GetTaxonomyPage(taxonomy string) *content.WebPage

func (*ContentHierarchy) GetTaxonomyTerms

func (ph *ContentHierarchy) GetTaxonomyTerms(taxonomy string) TermMap

func (*ContentHierarchy) Printf

func (ph *ContentHierarchy) Printf(format string, args ...interface{})

func (*ContentHierarchy) Println

func (ph *ContentHierarchy) Println(args ...interface{})

func (*ContentHierarchy) Retree

func (ph *ContentHierarchy) Retree()

func (*ContentHierarchy) SortedPages

func (ph *ContentHierarchy) SortedPages() []*content.WebPage

type ContentNode

type ContentNode struct {
	Page   *content.WebPage
	Parent string
}

type Feed

type Feed struct {
	Xmlns     string   `xml:"xmlns,attr"`
	Lang      string   `xml:"xml:lang,attr"`
	XMLName   xml.Name `xml:"feed"`
	Title     string   `xml:"title"`
	Subtitle  string   `xml:"subtitle"`
	Id        string   `xml:"id"`
	Links     []*FeedLink
	Generator *FeedGenerator
	Updated   FeedDateTime `xml:"updated"`
	Entries   []*FeedEntry
}

func (*Feed) WriteXML

func (f *Feed) WriteXML(atomFile io.Writer) error

type FeedAuthor

type FeedAuthor struct {
	XMLName xml.Name `xml:"author"`
	Name    string   `xml:"name"`
	Email   string   `xml:"email,omitempty"`
	Uri     string   `xml:"uri,omitempty"`
}

type FeedContent

type FeedContent struct {
	XMLName xml.Name `xml:"content"`
	Type    string   `xml:"type,attr"`
	Base    string   `xml:"base,attr,omitempty"`
	Content string   `xml:",chardata"`
}

type FeedDateTime

type FeedDateTime time.Time

func (FeedDateTime) MarshalXML

func (t FeedDateTime) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type FeedEntry

type FeedEntry struct {
	XMLName   xml.Name          `xml:"entry"`
	Lang      string            `xml:"xml:lang,attr"`
	Title     string            `xml:"title"`
	Id        string            `xml:"id"`
	Published FeedDateTime      `xml:"published"`
	Updated   FeedDateTime      `xml:"updated"`
	Content   *FeedContent      `xml:"content,omitempty"`
	Summary   *FeedEntrySummary `xml:"summary,omitempty"`
	Authors   []*FeedAuthor
	Links     []*FeedLink
}

type FeedEntrySummary

type FeedEntrySummary struct {
	XMLName xml.Name `xml:"summary"`
	Type    string   `xml:"type,attr"`
	Content string   `xml:",chardata"`
}

type FeedGenerator

type FeedGenerator struct {
	XMLName xml.Name `xml:"generator"`
	Uri     string   `xml:"uri,attr"`
	Name    string   `xml:",chardata"`
}
type FeedLink struct {
	XMLName xml.Name `xml:"link"`
	Rel     string   `xml:"rel,attr"`
	Type    string   `xml:"type,attr"`
	Href    string   `xml:"href,attr"`
}

type Generator

type Generator struct {
	Config *config.Config
	Tmpl   *template.Engine
	// contains filtered or unexported fields
}

func New

func New(cfg *config.Config, verbose bool) (*Generator, error)

func (*Generator) Build

func (g *Generator) Build(now time.Time) error

func (*Generator) ClearOutputDirectory

func (g *Generator) ClearOutputDirectory() error

func (*Generator) CopyStaticFiles

func (g *Generator) CopyStaticFiles() error

func (*Generator) FullUrl

func (g *Generator) FullUrl(path string) string

func (*Generator) GenerateFeed

func (g *Generator) GenerateFeed(now time.Time) error

func (*Generator) GeneratePage

func (g *Generator) GeneratePage(page *content.WebPage) (err error)

func (*Generator) GenerateSitemap

func (g *Generator) GenerateSitemap() error

func (*Generator) GetAllTaxonomyTerms

func (g *Generator) GetAllTaxonomyTerms(taxonomy string) (termTemplates []*TaxonomyTermContent)

func (*Generator) GetSectionPages

func (g *Generator) GetSectionPages(indexPath string, max int, offset int) (sectionPages []TemplateContent)

func (*Generator) GetTaxonomyTermsForPage

func (g *Generator) GetTaxonomyTermsForPage(rootPath string, taxonomy string) (termTemplates []*TaxonomyTermContent)

func (*Generator) GetTemplateToUse

func (g *Generator) GetTemplateToUse(page *content.WebPage) string

func (*Generator) OutputPath

func (g *Generator) OutputPath(endPath string) string

func (*Generator) PageToTemplateContent

func (g *Generator) PageToTemplateContent(page *content.WebPage) TemplateContent

func (*Generator) PagesToTemplateContents

func (g *Generator) PagesToTemplateContents(indexPage *content.WebPage) [][]TemplateContent

func (*Generator) Printf

func (g *Generator) Printf(format string, args ...interface{})

func (*Generator) Println

func (g *Generator) Println(args ...interface{})

func (*Generator) SiteUrlNoTrailingslash

func (g *Generator) SiteUrlNoTrailingslash() string

func (*Generator) SiteUrlWithTrailingSlash

func (g *Generator) SiteUrlWithTrailingSlash() string

type IndexTemplateContent

type IndexTemplateContent struct {
	TemplateContent
	Pages       []TemplateContent
	Prev        string
	Next        string
	CurrentPage int
	TotalPages  int
}

type PaginatedTemplateContent

type PaginatedTemplateContent struct {
	TemplateContent
	Prev     string
	PrevPage TemplateContent
	Next     string
	NextPage TemplateContent
}

type Sitemap

type Sitemap struct {
	XMLName xml.Name `xml:"urlset"`
	Xmlns   string   `xml:"xmlns,attr"`
	Urls    []*SitemapUrl
}

Sitemap represents the sitemap of the site.

func (*Sitemap) WriteXML

func (s *Sitemap) WriteXML(wr io.Writer) error

WriteXML writes the sitemap to the writer.

type SitemapUrl

type SitemapUrl struct {
	XMLName xml.Name `xml:"url"`
	Loc     string   `xml:"loc"`
}

SitemapUrl represents a URL in the sitemap.

type TaxonomyTermContent

type TaxonomyTermContent struct {
	Term      string
	PageCount int
	Permalink string
	RootPath  string
}

type TemplateContent

type TemplateContent struct {
	content.FrontMatter
	Content   htmltpl.HTML
	Config    config.Config
	Path      string
	RootPath  string
	Permalink string
	Summary   htmltpl.HTML
}

func (TemplateContent) GetExtra

func (t TemplateContent) GetExtra(key string) any

func (TemplateContent) HasExtra

func (t TemplateContent) HasExtra(key string) bool

type TermIndexTemplateContent

type TermIndexTemplateContent struct {
	TaxonomyTermContent
	IndexTemplateContent
}

type TermMap

type TermMap map[string][]*content.WebPage

type TermTTC

type TermTTC map[string]*TaxonomyTermContent

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL