model

package
v0.0.0-...-7635d6e Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContentTree

type ContentTree struct {
	// contains filtered or unexported fields
}

func NewContentTree

func NewContentTree(ctx context.Context, contentFS fs.FS, dir string) (*ContentTree, error)

func (*ContentTree) Children

func (content *ContentTree) Children() []Tree

func (*ContentTree) Name

func (content *ContentTree) Name() string

func (*ContentTree) Path

func (content *ContentTree) Path() string

func (*ContentTree) Walk

func (content *ContentTree) Walk(fn func(tree Tree) error) error

type File

type File struct {
	// contains filtered or unexported fields
}

func (*File) Children

func (f *File) Children() []Tree

func (*File) Name

func (f *File) Name() string

func (*File) Path

func (f *File) Path() string

func (*File) Walk

func (f *File) Walk(fn func(tree Tree) error) error

type FrontMatter

type FrontMatter struct {
	// Author of the page.
	Author string `json:"author"`
	// Title of the page.
	Title string `json:"title"`
	// Description is a short abstract of the page.
	Description string `json:"description"`
	// CreatedAt determines when the article was written.
	CreatedAt *frontmatter.SimpleDate `json:"created_at"`
	// Tags are list of words categorizing the page.
	Tags []string `json:"tags"`
	// Hidden excludes page from navigation menu.
	Hidden bool `json:"hidden"`
}

FrontMatter stores metadata of a page.

type MenuEntry struct {
	// Title of the menu entry.
	Title string
	// Path of the page file.
	Path string
	// IsDir is true if path is pointing to a directory.
	IsDir bool
}

MenuEntry is an entry in the navigation menu.

func Menu(tree Tree) []MenuEntry

Menu builds a slice of menu entries for the given content tree.

Note that the function will not recurse into the tree, instead the menu will only contain entries for the root level.

type Page

type Page struct {
	// contains filtered or unexported fields
}

func (*Page) Children

func (p *Page) Children() []Tree

func (*Page) Content

func (p *Page) Content() []byte

func (*Page) Frontmatter

func (p *Page) Frontmatter() *FrontMatter

func (*Page) Name

func (p *Page) Name() string

func (*Page) Path

func (p *Page) Path() string

func (*Page) Walk

func (p *Page) Walk(fn func(tree Tree) error) error

type Tree

type Tree interface {
	// Children returns a list of subtrees, if any.
	Children() []Tree
	// Path retuns the full path, starting from root of the tree.
	Path() string
	// Name returns the name of the tree node.
	Name() string
	// Walk calls func for every node in the (sub-)tree.
	Walk(func(Tree) error) error
}

Jump to

Keyboard shortcuts

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