context

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2016 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	Pages    []file.ParsedFile
	Articles []file.ParsedFile

	Tags, Categories []string

	Config  config.Config
	Updated string

	// Temporal stuff for template rendering
	Article     file.ParsedFile
	Page        file.ParsedFile
	Tag         string
	Category    string
	CurrentPage int
	// contains filtered or unexported fields
}

func New

func New(config config.Config) *Context

func (*Context) AppendUniqueCategory

func (c *Context) AppendUniqueCategory(newCategory string)

AppendUniqueCategory will append the category just in case that doesn't belong to the Context yet.

func (*Context) AppendUniqueTags

func (c *Context) AppendUniqueTags(newTags []string)

AppendUniqueTags will append the tag only if it's not already on the context.

func (Context) ArrayOfPages

func (c Context) ArrayOfPages() (pages []int)

ArrayOfPages is a dirty hack because we can not (or I don't know how) do a range from X to Y on the template

func (*Context) Copy

func (c *Context) Copy() *Context

func (Context) FilterByCategory

func (c Context) FilterByCategory(category string) []file.ParsedFile

FilterByCategory returns all the articles belonging to the give category.

func (Context) FilterByPage

func (c Context) FilterByPage(page int) []file.ParsedFile

FilterByPage returns the articles of the site paginated.

func (Context) FilterByTag

func (c Context) FilterByTag(tag string) []file.ParsedFile

FilterByTag returns all the articles belonging to the given tag.

func (Context) HumanizeDatetime

func (c Context) HumanizeDatetime(datetime time.Time) string

HumanizeDatetime returns a date or datetime depending of the datetime received. For example, if the datetime received doesn't have any hour/minutes, the hours/minutes part doesn't need to be shown.

func (Context) Len

func (c Context) Len() int

Len is needed to implement the sorting interface.

func (Context) Less

func (c Context) Less(i, j int) bool

Less is a comparator to help us to sort the context Articles by date DESC.

func (Context) NextSlug

func (c Context) NextSlug(page int) string

NextSlug "calculates" the next index slug given the page number.

func (Context) NumberOfPages

func (c Context) NumberOfPages() int

func (Context) PreviousSlug

func (c Context) PreviousSlug(page int) (slug string)

PreviousSlug "calculates" the previous index slug given the page number.

func (Context) ShowHeader

func (c Context) ShowHeader() bool

func (Context) Swap

func (c Context) Swap(i, j int)

Swap is needed to implement the sorting interface.

Jump to

Keyboard shortcuts

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