site

package
v0.0.0-...-32aeb84 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2018 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContentType

type ContentType int

ContentType blog or docs

const (
	ContentTypeBlog ContentType = iota
	ContentTypeDocs
)

List of content types

type FrontMatter

type FrontMatter struct {
	Time  time.Time
	Title string
	Vars  map[string]interface{}
	Tags  []string
}

FrontMatter is a metadata for Page

func (*FrontMatter) UnmarshalYAML

func (fm *FrontMatter) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements yaml.Unmarshaler interface

type IndexPage

type IndexPage struct {
	PagerItem
	Path  string
	Pages []*Page
	Next  *PagerItem
	Prev  *PagerItem
	Pager []*PagerItem
}

IndexPage is a colleciton of pages with pagination info

type Page

type Page struct {
	Content   []byte
	Summary   []byte
	Link      string
	Name      string
	Truncated bool
	Path      string
	Draft     bool

	Front *FrontMatter
}

Page is a parsed page

type PagerItem

type PagerItem struct {
	Number int
	Link   string
}

PagerItem is a pager entity

type Site

type Site struct {
	Pages      []*Page
	IndexPages []*IndexPage
	TagPages   map[string][]*IndexPage
	Tags       TagSet
	// contains filtered or unexported fields
}

Site is collection of content pages

func FromDir

func FromDir(f *fs.FS, conf *config.SiteConfig, dir string, contentType ContentType) (*Site, error)

FromDir loads Site from given directory, recurcively

func (*Site) AllTags

func (s *Site) AllTags() []string

AllTags returns all tags sorted by popularity desc

func (*Site) ByPath

func (s *Site) ByPath(path string) *Page

ByPath returns page by path

func (*Site) Rebuild

func (s *Site) Rebuild(f *fs.FS, path string) error

Rebuild reloads page from file

type TagSet

type TagSet map[string]struct{}

TagSet is a set of tags

func (TagSet) Add

func (ts TagSet) Add(tags []string)

Add adds tag to set if it not in there

func (TagSet) All

func (ts TagSet) All() []string

All returns slice of all tags

Jump to

Keyboard shortcuts

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