Documentation ¶
Index ¶
- Variables
- func HandleShortcodes(stringToParse string, page *Page, t tpl.Template) (string, error)
- func HandlerMatch(h Handler, ext string) bool
- func RegisterHandler(h Handler)
- type Author
- type AuthorList
- type AuthorSocial
- type Handle
- type HandleResults
- type HandledResult
- type Handler
- type HugoInfo
- type Image
- type Menu
- type MenuEntry
- type Menus
- type MetaHandle
- type MetaHandler
- type Node
- func (n *Node) HasMenuCurrent(menuID string, inme *MenuEntry) bool
- func (n *Node) Hugo() *HugoInfo
- func (n *Node) IsMenuCurrent(menuID string, inme *MenuEntry) bool
- func (n *Node) IsNode() bool
- func (n *Node) IsPage() bool
- func (n *Node) Now() time.Time
- func (n *Node) Paginate(seq interface{}, options ...interface{}) (*Pager, error)
- func (n *Node) Paginator(options ...interface{}) (*Pager, error)
- func (n *Node) Param(key interface{}) (interface{}, error)
- func (n *Node) RSSlink() template.HTML
- func (n *Node) Ref(ref string) (string, error)
- func (n *Node) RelRef(ref string) (string, error)
- func (n *Node) Scratch() *Scratch
- type OrderedTaxonomy
- type OrderedTaxonomyEntry
- type Page
- func (p *Page) Author() Author
- func (p *Page) Authors() AuthorList
- func (p *Page) Convert() error
- func (p *Page) Extension() string
- func (p *Page) FullFilePath() string
- func (p *Page) GetParam(key string) interface{}
- func (p *Page) HasMenuCurrent(menu string, me *MenuEntry) bool
- func (p *Page) IsDraft() bool
- func (p *Page) IsFuture() bool
- func (p *Page) IsMenuCurrent(menu string, inme *MenuEntry) bool
- func (p *Page) IsNode() bool
- func (p *Page) IsPage() bool
- func (p *Page) IsRenderable() bool
- func (p *Page) LinkTitle() string
- func (p *Page) Menus() PageMenus
- func (p *Page) Paginate(seq interface{}, options ...interface{}) (*Pager, error)
- func (p *Page) Paginator(options ...interface{}) (*Pager, error)
- func (p *Page) Param(key interface{}) (interface{}, error)
- func (p *Page) Permalink() (string, error)
- func (p *Page) Plain() string
- func (p *Page) PlainWords() []string
- func (p *Page) ProcessShortcodes(t tpl.Template)
- func (p *Page) RawContent() string
- func (p *Page) ReadFrom(buf io.Reader) (int64, error)
- func (p *Page) Ref(ref string) (string, error)
- func (p *Page) RelPermalink() (string, error)
- func (p *Page) RelRef(ref string) (string, error)
- func (p *Page) Render(layout ...string) template.HTML
- func (p *Page) SafeSaveSourceAs(path string) error
- func (p *Page) SaveSource() error
- func (p *Page) SaveSourceAs(path string) error
- func (p *Page) Section() string
- func (p *Page) SetSourceContent(content []byte)
- func (p *Page) SetSourceMetaData(in interface{}, mark rune) (err error)
- func (p *Page) ShouldBuild() bool
- func (p *Page) TargetPath() (outfile string)
- func (p *Page) Type() string
- func (p *Page) UniqueID() string
- type PageGroup
- type PageMenus
- type PageMeta
- type Pager
- func (p *Pager) First() *Pager
- func (p *Pager) HasNext() bool
- func (p *Pager) HasPrev() bool
- func (p *Pager) Last() *Pager
- func (p *Pager) Next() *Pager
- func (p *Pager) NumberOfElements() int
- func (p *Pager) PageGroups() PagesGroup
- func (p *Pager) PageNumber() int
- func (p Pager) PageSize() int
- func (p Pager) Pagers() pagers
- func (p *Pager) Pages() Pages
- func (p *Pager) Prev() *Pager
- func (p Pager) TotalNumberOfElements() int
- func (p Pager) TotalPages() int
- func (p *Pager) URL() template.HTML
- type Pages
- func (p Pages) ByDate() Pages
- func (p Pages) ByLength() Pages
- func (p Pages) ByLinkTitle() Pages
- func (p Pages) ByPublishDate() Pages
- func (p Pages) ByTitle() Pages
- func (p Pages) ByWeight() Pages
- func (ps Pages) FindPagePos(page *Page) int
- func (ps Pages) FindPagePosByFilePath(inPath string) int
- func (p Pages) GroupBy(key string, order ...string) (PagesGroup, error)
- func (p Pages) GroupByDate(format string, order ...string) (PagesGroup, error)
- func (p Pages) GroupByParam(key string, order ...string) (PagesGroup, error)
- func (p Pages) GroupByParamDate(key string, format string, order ...string) (PagesGroup, error)
- func (p Pages) GroupByPublishDate(format string, order ...string) (PagesGroup, error)
- func (p Pages) Len() int
- func (p Pages) Limit(n int) Pages
- func (p Pages) Next(cur *Page) *Page
- func (p Pages) Prev(cur *Page) *Page
- func (p Pages) Reverse() Pages
- func (p Pages) Sort()
- type PagesGroup
- type PermalinkOverrides
- type Position
- type Scratch
- func (c *Scratch) Add(key string, newAddend interface{}) (string, error)
- func (c *Scratch) Get(key string) interface{}
- func (c *Scratch) GetSortedMapValues(key string) interface{}
- func (c *Scratch) Set(key string, value interface{}) string
- func (c *Scratch) SetInMap(key string, mapKey string, value interface{}) string
- type ShortcodeWithPage
- type Site
- func (s *Site) Analyze() error
- func (s *Site) Build() (err error)
- func (s *Site) Initialise() (err error)
- func (s *Site) Process() (err error)
- func (s *Site) ReBuild(events []fsnotify.Event) error
- func (s *Site) Render() (err error)
- func (s *Site) ShowPlan(out io.Writer) (err error)
- func (s *Site) Stats()
- type SiteInfo
- func (s *SiteInfo) GetParam(key string) interface{}
- func (s *SiteInfo) Ref(ref string, page *Page) (string, error)
- func (s *SiteInfo) RelRef(ref string, page *Page) (string, error)
- func (s *SiteInfo) SourceRelativeLink(ref string, currentPage *Page) (string, error)
- func (s *SiteInfo) SourceRelativeLinkFile(ref string, currentPage *Page) (string, error)
- type SiteSocial
- type Sitemap
- type Source
- type Taxonomy
- type TaxonomyList
- type URLPath
- type Video
- type WeightedPage
- type WeightedPages
- func (wp WeightedPages) Count() int
- func (wp WeightedPages) Len() int
- func (wp WeightedPages) Less(i, j int) bool
- func (wp WeightedPages) Next(cur *Page) *Page
- func (wp WeightedPages) Pages() Pages
- func (wp WeightedPages) Prev(cur *Page) *Page
- func (wp WeightedPages) Sort()
- func (wp WeightedPages) Swap(i, j int)
Constants ¶
This section is empty.
Variables ¶
var ( // CommitHash contains the current Git revision. Use make to build to make // sure this gets set. CommitHash string // BuildDate contains the date of the current build. BuildDate string )
var ErrHasDraftAndPublished = errors.New("both draft and published parameters were found in page's frontmatter")
Functions ¶
func HandleShortcodes ¶
HandleShortcodes does all in one go: extract, render and replace only used for testing
func HandlerMatch ¶
func RegisterHandler ¶
func RegisterHandler(h Handler)
Types ¶
type Author ¶
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 ¶
AuthorList is a list of all authors and their metadata.
type AuthorSocial ¶
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 - googleplus - pinterest - instagram - youtube - linkedin - skype
type Handle ¶
type Handle struct {
// contains filtered or unexported fields
}
func (Handle) Extensions ¶
type HandleResults ¶
type HandleResults chan<- HandledResult
type HandledResult ¶
type HandledResult struct {
// contains filtered or unexported fields
}
func (HandledResult) Page ¶
func (h HandledResult) Page() *Page
func (HandledResult) String ¶
func (h HandledResult) String() string
type Handler ¶
type Handler interface { FileConvert(*source.File, *Site) HandledResult PageConvert(*Page, tpl.Template) HandledResult Read(*source.File, *Site) HandledResult Extensions() []string }
func FindHandler ¶
type Image ¶
type Image struct { // The URL of the image. In some cases, the image URL may not be on the // same domain as your main site. This is fine, as long as both domains // are verified in Webmaster Tools. If, for example, you use a // content delivery network (CDN) to host your images, make sure that the // hosting site is verified in Webmaster Tools OR that you submit your // sitemap using robots.txt. In addition, make sure that your robots.txt // file doesn’t disallow the crawling of any content you want indexed. URL string Title string Caption string AltText string // The geographic location of the image. For example, // <image:geo_location>Limerick, Ireland</image:geo_location>. GeoLocation string // A URL to the license of the image. License string }
An Image contains metadata for images + image sitemaps https://support.google.com/webmasters/answer/178636?hl=en
type Menu ¶
type Menu []*MenuEntry
Menu is a collection of menu entries.
type MenuEntry ¶
type MenuEntry struct { URL string Name string Menu string Identifier string Pre template.HTML Post template.HTML Weight int Parent string Children Menu }
MenuEntry represents a menu item defined in either Page front matter or in the site config.
func (*MenuEntry) HasChildren ¶
HasChildren returns whether this menu item has any children.
func (*MenuEntry) IsEqual ¶
IsEqual returns whether the two menu entries represents the same menu entry.
func (*MenuEntry) IsSameResource ¶
IsSameResource returns whether the two menu entries points to the same resource (URL).
type MetaHandle ¶
type MetaHandle struct {
// contains filtered or unexported fields
}
func NewMetaHandler ¶
func NewMetaHandler(in string) *MetaHandle
func (*MetaHandle) Convert ¶
func (mh *MetaHandle) Convert(i interface{}, s *Site, results HandleResults)
func (*MetaHandle) Handler ¶
func (mh *MetaHandle) Handler() Handler
func (*MetaHandle) Read ¶
func (mh *MetaHandle) Read(f *source.File, s *Site, results HandleResults)
type MetaHandler ¶
type MetaHandler interface { // Read the Files in and register Read(*source.File, *Site, HandleResults) // Generic Convert Function with coordination Convert(interface{}, *Site, HandleResults) Handle() Handler }
type Node ¶
type Node struct { RSSLink template.HTML Site *SiteInfo `json:"-"` // layout string Data map[string]interface{} Title string Description string Keywords []string Params map[string]interface{} Date time.Time Lastmod time.Time Sitemap Sitemap URLPath IsHome bool // contains filtered or unexported fields }
func (*Node) Paginate ¶
Paginate gets this Node's paginator if it's already created. If it's not, one will be created with the qiven sequence. Note that repeated calls will return the same result, even if the sequence is different.
func (*Node) Paginator ¶
Paginator gets this Node's paginator if it's already created. If it's not, one will be created with all pages in Data["Pages"].
type OrderedTaxonomy ¶
type OrderedTaxonomy []OrderedTaxonomyEntry
OrderedTaxonomy is another representation of an Taxonomy using an array rather than a map. Important because you can't order a map.
func (OrderedTaxonomy) Reverse ¶
func (t OrderedTaxonomy) Reverse() OrderedTaxonomy
Reverse reverses the order of the entries in this taxonomy.
type OrderedTaxonomyEntry ¶
type OrderedTaxonomyEntry struct { Name string WeightedPages WeightedPages }
OrderedTaxonomyEntry is similar to an element of a Taxonomy, but with the key embedded (as name) e.g: {Name: Technology, WeightedPages: Taxonomyedpages}
func (OrderedTaxonomyEntry) Count ¶
func (ie OrderedTaxonomyEntry) Count() int
Count returns the count the pages in this taxonomy.
func (OrderedTaxonomyEntry) Pages ¶
func (ie OrderedTaxonomyEntry) Pages() Pages
Pages returns the Pages for this taxonomy.
func (OrderedTaxonomyEntry) Term ¶
func (ie OrderedTaxonomyEntry) Term() string
Term returns the name given to this taxonomy.
type Page ¶
type Page struct { Params map[string]interface{} Content template.HTML Summary template.HTML Aliases []string Status string Images []Image Videos []Video TableOfContents template.HTML Truncated bool Draft bool PublishDate time.Time Markup string Layout string PageMeta Source Position `json:"-"` Node // contains filtered or unexported fields }
func (*Page) Authors ¶
func (p *Page) Authors() AuthorList
func (*Page) Convert ¶
TODO(spf13): Remove this entirely Here for backwards compatibility & testing. Only works in isolation
func (*Page) FullFilePath ¶
func (*Page) IsRenderable ¶
func (*Page) Param ¶
Param is a convenience method to do lookups in Page's and Site's Params map, in that order.
This method is also implemented on Node.
func (*Page) PlainWords ¶
func (*Page) ProcessShortcodes ¶
func (*Page) RawContent ¶
func (*Page) RelPermalink ¶
func (*Page) SafeSaveSourceAs ¶
func (*Page) SaveSource ¶
func (*Page) SaveSourceAs ¶
func (*Page) SetSourceContent ¶
func (*Page) SetSourceMetaData ¶
func (*Page) ShouldBuild ¶
func (*Page) TargetPath ¶
type PageGroup ¶
type PageGroup struct { Key interface{} Pages Pages }
PageGroup represents a group of pages, grouped by the key. The key is typically a year or similar.
type Pager ¶
type Pager struct {
// contains filtered or unexported fields
}
Pager represents one of the elements in a paginator. The number, starting on 1, represents its place.
func (*Pager) NumberOfElements ¶
NumberOfElements gets the number of elements on this page.
func (*Pager) PageGroups ¶
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 ¶
PageNumber returns the current page's number in the pager sequence.
func (Pager) PageSize ¶
func (p Pager) PageSize() int
PageSize returns the size of each paginator page.
func (Pager) Pagers ¶
func (p Pager) Pagers() pagers
Pagers returns a list of pagers that can be used to build a pagination menu.
func (*Pager) Pages ¶
Pages returns the Pages on this page. Note: If this return a non-empty result, then PageGroups() will return empty.
func (Pager) TotalNumberOfElements ¶
func (p Pager) TotalNumberOfElements() int
TotalNumberOfElements returns the number of elements on all pages in this paginator.
func (Pager) TotalPages ¶
func (p Pager) TotalPages() int
TotalPages returns the number of pages in the paginator.
type Pages ¶
type Pages []*Page
func (Pages) ByDate ¶
ByDate sorts the Pages by date and returns a copy.
Adjacent invocactions on the same receiver will return a cached result.
This may safely be executed in parallel.
func (Pages) ByLength ¶
ByLength sorts the Pages by length and returns a copy.
Adjacent invocactions on the same receiver will return a cached result.
This may safely be executed in parallel.
func (Pages) ByLinkTitle ¶
ByLinkTitle sorts the Pages by link title and returns a copy.
Adjacent invocactions on the same receiver will return a cached result.
This may safely be executed in parallel.
func (Pages) ByPublishDate ¶
ByPublishDate sorts the Pages by publish date and returns a copy.
Adjacent invocactions on the same receiver will return a cached result.
This may safely be executed in parallel.
func (Pages) ByTitle ¶
ByTitle sorts the Pages by title and returns a copy.
Adjacent invocactions on the same receiver will return a cached result.
This may safely be executed in parallel.
func (Pages) ByWeight ¶
ByWeight sorts the Pages by weight and returns a copy.
Adjacent invocactions on the same receiver will return a cached result.
This may safely be executed in parallel.
func (Pages) FindPagePos ¶
FindPagePos Given a page, it will find the position in Pages will return -1 if not found
func (Pages) FindPagePosByFilePath ¶
func (Pages) GroupBy ¶
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 ¶
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) GroupByParam ¶
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 ¶
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 ¶
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
type PagesGroup ¶
type PagesGroup []PageGroup
PagesGroup represents a list of page groups. This is what you get when doing page grouping in the templates.
func (PagesGroup) Len ¶
func (psg PagesGroup) Len() int
Len returns the number of pages in the page group.
func (PagesGroup) Reverse ¶
func (p PagesGroup) Reverse() PagesGroup
Reverse reverses the order of this list of page groups.
type PermalinkOverrides ¶
type PermalinkOverrides map[string]pathPattern
PermalinkOverrides maps a section name to a PathPattern
type Scratch ¶
type Scratch struct {
// contains filtered or unexported fields
}
Scratch is a writable context used for stateful operations in Page/Node rendering.
func (*Scratch) Add ¶
Add will, for single values, add (using the + operator) the addend to the existing addend (if found). Supports numeric values and strings.
If the first add for a key is an array or slice, then the next value(s) will be appended.
func (*Scratch) GetSortedMapValues ¶
GetSortedMapValues returns a sorted map previously filled with SetInMap
type ShortcodeWithPage ¶
type ShortcodeWithPage struct { Params interface{} Inner template.HTML Page *Page Parent *ShortcodeWithPage IsNamedParams bool // contains filtered or unexported fields }
ShortcodeWithPage is the "." context in a shortcode template.
func (*ShortcodeWithPage) Get ¶
func (scp *ShortcodeWithPage) Get(key interface{}) interface{}
Get is a convenience method to look up shortcode parameters by its key.
func (*ShortcodeWithPage) Ref ¶
func (scp *ShortcodeWithPage) Ref(ref string) (string, error)
Ref is a shortcut to the Ref method on Page.
func (*ShortcodeWithPage) RelRef ¶
func (scp *ShortcodeWithPage) RelRef(ref string) (string, error)
RelRef is a shortcut to the RelRef method on Page.
func (*ShortcodeWithPage) Scratch ¶
func (scp *ShortcodeWithPage) Scratch() *Scratch
Scratch returns a scratch-pad scoped for this shortcode. This can be used as a temporary storage for variables, counters etc.
func (*ShortcodeWithPage) Site ¶
func (scp *ShortcodeWithPage) Site() *SiteInfo
Site returns information about the current site.
type Site ¶
type Site struct { Pages Pages Files []*source.File Tmpl tpl.Template Taxonomies TaxonomyList Source source.Input Sections Taxonomy Info SiteInfo Menus Menus RunMode runmode Data map[string]interface{} // contains filtered or unexported fields }
Site contains all the information relevant for constructing a static site. The basic flow of information is as follows:
1. A list of Files is parsed and then converted into Pages.
- Pages contain sections (based on the file they were generated from), aliases and slugs (included in a pages frontmatter) which are the various targets that will get generated. There will be canonical listing. The canonical path can be overruled based on a pattern.
- Taxonomies are created via configuration and will present some aspect of the final page and typically a perm url.
- All Pages are passed through a template based on their desired layout based on numerous different elements.
5. The entire collection of files is written to disk.
func (*Site) Initialise ¶
type SiteInfo ¶
type SiteInfo struct { BaseURL template.URL Taxonomies TaxonomyList Authors AuthorList Social SiteSocial Sections Taxonomy Pages *Pages Files *[]*source.File Menus *Menus Hugo *HugoInfo Title string RSSLink string Author map[string]interface{} LanguageCode string DisqusShortname string GoogleAnalytics string Copyright string LastChange time.Time Permalinks PermalinkOverrides Params map[string]interface{} BuildDrafts bool Data *map[string]interface{} // contains filtered or unexported fields }
func (*SiteInfo) SourceRelativeLink ¶
SourceRelativeLink attempts to convert any source page relative links (like [../another.md]) into absolute links
type SiteSocial ¶
SiteSocial is a place to put social details on a site level. These are the standard keys that themes will expect to have available, but can be expanded to any others on a per site basis github facebook facebook_admin twitter twitter_domain googleplus pinterest instagram youtube linkedin
type Taxonomy ¶
type Taxonomy map[string]WeightedPages
A Taxonomy is a map of keywords to a list of pages. For example
TagTaxonomy['technology'] = WeightedPages TagTaxonomy['go'] = WeightedPages2
func (Taxonomy) Alphabetical ¶
func (i Taxonomy) Alphabetical() OrderedTaxonomy
Alphabetical returns an ordered taxonomy sorted by key name.
func (Taxonomy) ByCount ¶
func (i Taxonomy) ByCount() OrderedTaxonomy
ByCount returns an ordered taxonomy sorted by # of pages per key. If taxonomies have the same # of pages, sort them alphabetical
func (Taxonomy) Get ¶
func (i Taxonomy) Get(key string) WeightedPages
Get the weighted pages for the given key.
func (Taxonomy) TaxonomyArray ¶
func (i Taxonomy) TaxonomyArray() OrderedTaxonomy
TaxonomyArray returns an ordered taxonomy with a non defined order.
type TaxonomyList ¶
The TaxonomyList is a list of all taxonomies and their values e.g. List['tags'] => TagTaxonomy (from above)
type Video ¶
type Video struct { ThumbnailLoc string Title string Description string ContentLoc string PlayerLoc string Duration string ExpirationDate string Rating string ViewCount string PublicationDate string FamilyFriendly string Restriction string GalleryLoc string Price string RequiresSubscription string Uploader string Live string }
A Video contains metadata for videos + video sitemaps https://support.google.com/webmasters/answer/80471?hl=en
type WeightedPage ¶
A WeightedPage is a Page with a weight.
type WeightedPages ¶
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 ¶
func (wp WeightedPages) Count() int
Count returns the number of pages in this weighted page set.
func (WeightedPages) Len ¶
func (wp WeightedPages) Len() int
func (WeightedPages) Less ¶
func (wp WeightedPages) Less(i, j int) bool
func (WeightedPages) Next ¶
func (wp WeightedPages) Next(cur *Page) *Page
Next returns the next Page relative to the given Page in this weighted page set.
func (WeightedPages) Pages ¶
func (wp WeightedPages) Pages() Pages
Pages returns the Pages in this weighted page set.
func (WeightedPages) Prev ¶
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 ¶
func (wp WeightedPages) Sort()
Sort stable sorts this weighted page set.
func (WeightedPages) Swap ¶
func (wp WeightedPages) Swap(i, j int)