Documentation ¶
Index ¶
- Constants
- func Render(e Entry) string
- type BaseContext
- type ByAge
- type Entry
- type ErrorContext
- type Index
- type IndexContext
- type NavItemContext
- type NavigationLink
- type Page
- type PageContext
- type ParseData
- type Post
- type PostContext
- type Templater
- func (t *Templater) AddNavItem(e Entry)
- func (t *Templater) ClearCache()
- func (t *Templater) ClearNav()
- func (t *Templater) NewBaseContext() *BaseContext
- func (t *Templater) NewErrorContext(err error) *ErrorContext
- func (t *Templater) NewIndexContext() *IndexContext
- func (t *Templater) NewPageContext(slug string) (*PageContext, error)
- func (t *Templater) NewPostContext(slug string) (*PostContext, error)
- func (t *Templater) RenderPage(w io.Writer, name string, context interface{}) error
- type URLResolver
Constants ¶
const ( // PostsFolder is the default folder for blog posts. PostsFolder = "posts" // PagesFolder is the default folder for blog pages. PagesFolder = "pages" // FileDateFormat is the date format required in a post's header. FileDateFormat = "2006-Jan-02" )
const ( TemplateFolder = "templates" DisplayFolder = "displays" IncludeFolder = "includes" )
TemplatesFolder is the default folder for templates.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BaseContext ¶
type BaseContext struct { BlogTitle string BlogSubtitle string BlogAuthor string BlogYear string BlogEmail string BlogURL string }
BaseContext stores basic context information like title, author etc.
type ByAge ¶
type ByAge []Post
ByAge implements a interface to sort a slice of posts by publishing date.
type ErrorContext ¶
type ErrorContext struct { BaseContext Message string }
ErrorContext stores error information.
type Index ¶
type Index struct { // Posts stores all blog posts. Posts []Post // Pages stores all blog pages. Pages []Page // PostBySlug matches each slug to its post. PostBySlug map[string]*Post // PageBySlug matches each slug to its page. PageBySlug map[string]*Page Resolver URLResolver }
func (*Index) LatestPosts ¶
LatestPosts returns a slice of the latest blog posts.
type IndexContext ¶
type IndexContext struct { BaseContext LatestPosts []Post }
IndexContext stores a list of the latest posts.
type NavItemContext ¶
type NavItemContext struct {}
NavItemContext stores the information of a navigation item.
type NavigationLink ¶
type NavigationLink struct {}
func (*NavigationLink) GetContent ¶
func (n *NavigationLink) GetContent() string
func (*NavigationLink) GetTitle ¶
func (n *NavigationLink) GetTitle() string
func (*NavigationLink) GetURL ¶
func (n *NavigationLink) GetURL() string
type Page ¶
type Page struct { Title string Slug string Content string Resolver URLResolver }
Page stores a title, a page slug and the body content.
func (*Page) GetContent ¶
GetContent returns the content body of the page.
type PageContext ¶
type PageContext struct { BaseContext PageTitle string PageContent template.HTML PageURL string }
PageContext stores additional information for pages.
type ParseData ¶
type ParseData struct { Title string `yaml:"title"` Subtitle string `yaml:"subtitle"` PublishDate string `yaml:"date"` Slug string `yaml:"slug"` // contains filtered or unexported fields }
ParseData stores the parsed data of a file.
func (*ParseData) SetContent ¶
SetContent sets the parsed content.
type Post ¶
type Post struct { Title string Subtitle string PublishDate time.Time Slug string Content string Resolver URLResolver }
Post stores a title, a page slug and the body content.
func (*Post) GetContent ¶
GetContent returns the content body of the post.
type PostContext ¶
type PostContext struct { BaseContext PostTitle string PostSubtitle string PostDate string PostContent template.HTML PostURL string }
PostContext stores additional information for posts.
type Templater ¶
func NewTemplater ¶
NewTemplater loads the templates from the blog folder.
func (*Templater) AddNavItem ¶
AddNavItem adds a item to the navigation.
func (*Templater) ClearCache ¶
func (t *Templater) ClearCache()
ClearCache clears the context cache.
func (*Templater) NewBaseContext ¶
func (t *Templater) NewBaseContext() *BaseContext
NewBaseContext either creates a new BaseContext from the global blog configuration or returns the cached version.
func (*Templater) NewErrorContext ¶
func (t *Templater) NewErrorContext(err error) *ErrorContext
NewErrorContext creates a new error context.
func (*Templater) NewIndexContext ¶
func (t *Templater) NewIndexContext() *IndexContext
NewIndexContext either creates a new index context or returns the cached version.
func (*Templater) NewPageContext ¶
func (t *Templater) NewPageContext(slug string) (*PageContext, error)
NewPageContext either creates a new page context or returns the cached version.
func (*Templater) NewPostContext ¶
func (t *Templater) NewPostContext(slug string) (*PostContext, error)
NewPostContext either creates a new post context or returns the cached version.