node

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: May 27, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NodeTypePage = "page"
	NodeTypePost = "post"
)

Variables

This section is empty.

Functions

func Create

func Create(site *baja.Site, dir, title string) int

Types

type CreateCommand

type CreateCommand struct{}

func (*CreateCommand) ArgDesc

func (cmd *CreateCommand) ArgDesc() string

func (*CreateCommand) Help

func (cmd *CreateCommand) Help() string

func (*CreateCommand) Run

func (cmd *CreateCommand) Run(site *baja.Site, args []string) int

type IndexNode

type IndexNode struct {
	Dir     string
	Nodes   []*Node
	Current *baja.Current
}

func NewIndex

func NewIndex(dir string, nodes []*Node) *IndexNode

func (*IndexNode) Compile

func (n *IndexNode) Compile(site *baja.Site)

type ListPage

type ListPage struct {
	Current   *baja.Current
	Title     string
	Permalink string
	Nodes     []map[string]interface{}
}

ListPage is an index page, it isn't constructed from a markdown file but from a list of related markdown such as tag or category

type Node

type Node struct {
	Meta *NodeMeta
	Body template.HTML

	Raw           string // raw text content
	Path          string // full absolute path to markdown file
	BaseDirectory string // the directory without /content part
	Name          string // the filename without extension
	// contains filtered or unexported fields
}

Node hold information of a specifc page we are rendering

func NewNode

func NewNode(site *baja.Site, path string) *Node

NewNode creates a Node object from a path

func (*Node) Compile

func (n *Node) Compile()

func (*Node) FindTheme

func (n *Node) FindTheme(site *baja.Site)

func (*Node) IsPage

func (n *Node) IsPage() bool

func (*Node) Parse

func (n *Node) Parse()

Parse reads the markdown and parse metadata and generate html

func (n *Node) Permalink() string

type NodeDB

type NodeDB struct {
	NodeList      []*Node
	DirectoryList []string
	Total         int
	Site          *baja.Site
}

NodeDB is the in-memory database of all the page

func BuildDB

func BuildDB(site *baja.Site, ctx *baja.Context) *NodeDB

BuildDB calculate a tree to represent all of node This tree can be query/group/filter

func (*NodeDB) All

func (db *NodeDB) All() []*Node

func (*NodeDB) Append

func (db *NodeDB) Append(n *Node)

func (*NodeDB) ByCategory

func (db *NodeDB) ByCategory() map[string][]*Node

ByTag category groups node by category(category is the directoy name)

func (*NodeDB) ByTag

func (db *NodeDB) ByTag() map[string][]*Node

ByTag groups node by tag

func (*NodeDB) Publishable

func (db *NodeDB) Publishable() []*Node

Publishable returns a list of node that can be publish, as in non-draft mode or non page

type NodeMeta

type NodeMeta struct {
	Title         string
	Draft         bool
	Date          time.Time
	DateFormatted string
	Tags          []string
	Category      string
	Type          string // node type. Eg page or post
	Theme         string // a custom template file inside theme directory without extension
}

NodeMeta is meta data of a node, usually map directly to node toml metadata section

Jump to

Keyboard shortcuts

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