baja

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2019 License: MIT Imports: 17 Imported by: 0

README

baja

A minimal static site generator

Concept

Baja simply looks at a directory and find file recursive and render individual page in a layout plus an index page of each directory.

To look up the template for render, if it's a single page, it use themes/name/node.html. If it's an index, it used list.html.

Plus, if it has an index.html page, that template are used to render index of whole site. otherwise it used list.html.

Getting started

The API is similar to git

# First time, bootstrap
baja new

# Add a post
baja add directory/post/

# Import from Gist or Evernote
baja import url

# Spit out static file
baja build

# You need to have 
baja deploy s3

# of if you're using Github page
baja deploy github

Why the name

When my daughter started to speak, baja was one the word she kept saying for no reason. No one in family know what it means. It remains unknow nowsaday and she eventually stop saying when she know more words

But the word baja light up my days a lot.

Release

  • 2019/02/09: 0.0.2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build() int

Build execute template and content to generate our real static conent

func BuildIndex

func BuildIndex(dir string, nodes []*Node, current *Current)

func Clean

func Clean()

func CompileAsset added in v0.0.2

func CompileAsset(config *Config)

func CompileNodes added in v0.0.2

func CompileNodes(db *NodeDB)

func CreateNode

func CreateNode(dir, title string) error

func Run

func Run(addr, public string)

func Serve

func Serve(addr, directory string) int

Build execute template and content to generate our real static conent

func Setup

func Setup(name string) error

Initalize a new blog directory

func Watch added in v0.0.3

func Watch(dir string) (*fsnotify.Watcher, error)

Types

type Config

type Config struct {
	Theme string `"yaml":theme`
	Site  string `"yaml":site`
	// contains filtered or unexported fields
}

func DefaultConfig

func DefaultConfig() *Config

func NewConfig

func NewConfig(path string) *Config

func (*Config) WriteFile

func (c *Config) WriteFile()

type Current added in v0.0.2

type Current struct {
	IsHome bool
	IsDir  bool
	IsTag  bool
	IsList bool

	CompiledAt time.Time
}

type ListPage added in v0.0.2

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

type Node

type Node struct {
	Meta *NodeMeta
	Body template.HTML
	Name string // the filename without extension

	Raw           string
	Path          string
	BaseDirectory string // the directory without /content part
	// contains filtered or unexported fields
}

func NewNode

func NewNode(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(c *Config)

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
}

func BuildDB added in v0.0.2

func BuildDB(config *Config) *NodeDB

func (*NodeDB) Append added in v0.0.2

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

func (*NodeDB) ByCategory added in v0.0.2

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

func (*NodeDB) ByTag added in v0.0.2

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

func (*NodeDB) Publishable added in v0.0.2

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

type NodeMeta

type NodeMeta struct {
	Title         string
	Draft         bool
	Date          time.Time
	DateFormatted string
	Tags          []string
	Category      string
	Type          string
}

type Server

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

type Site

type Site struct {
	Name    string
	Author  string
	BaseUrl string

	Config *SiteConfig
}

type SiteConfig

type SiteConfig struct {
	Name    string `"yaml":name`
	Author  string `"yaml":author`
	BaseURL string `"yaml":baseURL`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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