taragen

package module
v0.0.0-...-0f08e28 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2025 License: MIT Imports: 24 Imported by: 0

README

taragen

Fast, minimal static site generator

Features

  • Supports JSX pages, partials, and layouts
  • Markdown pages with frontmatter data
  • Customizable JS global helpers
  • Global and per-directory data
  • Single binary executable

Documentation

Index

Constants

View Source
const (
	ExtMarkdown = ".md"
	ExtTemplate = ".tmpl"
	ExtJSX      = ".jsx"
)
View Source
const (
	Layout      = "layout"
	Slug        = "slug"
	Path        = "path"
	Source      = "src"
	Body        = "body"
	IsDir       = "isDir"
	Date        = "date"
	ContentType = "contentType"
	Draft       = "draft"
	Preamble    = "preamble"
)

Variables

Functions

func ExportJSX

func ExportJSX(name string, src []byte, globals map[string]any) (map[string]any, error)

func RenderJSX

func RenderJSX(name string, src []byte, globals map[string]any, args ...any) ([]byte, error)

func RenderTemplate

func RenderTemplate(name string, src []byte, funcs template.FuncMap) ([]byte, error)

Types

type Data

type Data map[string]any

func SplitFrontmatter

func SplitFrontmatter(src []byte) (Data, []byte, error)

type JSXParser

type JSXParser struct{}

func (*JSXParser) Parse

func (f *JSXParser) Parse(p *Page) (out []byte, data Data, err error)

type MarkdownParser

type MarkdownParser struct{}

func (*MarkdownParser) Parse

func (f *MarkdownParser) Parse(p *Page) ([]byte, Data, error)

type Page

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

func (*Page) Body

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

func (*Page) ContentType

func (p *Page) ContentType() string

func (*Page) Date

func (p *Page) Date() string

func (*Page) Draft

func (p *Page) Draft() bool

func (*Page) IsDir

func (p *Page) IsDir() bool

func (*Page) Parse

func (p *Page) Parse() error

func (*Page) Preamble

func (p *Page) Preamble() string

func (*Page) Render

func (p *Page) Render(w io.Writer) (err error)

func (*Page) Slug

func (p *Page) Slug() string

func (*Page) Source

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

func (*Page) Subpages

func (p *Page) Subpages() (subpages []*Page)

func (*Page) Time

func (p *Page) Time() time.Time

type PageParser

type PageParser interface {
	Parse(p *Page) ([]byte, Data, error)
}

type Site

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

func NewSite

func NewSite(dir string, drafts bool) *Site

func (*Site) GenerateAll

func (s *Site) GenerateAll(dest string, clobber bool) (err error)

func (*Site) IsPage

func (s *Site) IsPage(path string) bool

func (*Site) Page

func (s *Site) Page(normalPath string) *Page

func (*Site) Pages

func (s *Site) Pages(name string) (pages []*Page)

func (*Site) ParseAll

func (s *Site) ParseAll() error

func (*Site) Partial

func (s *Site) Partial(name string, globals map[string]any, args ...any) ([]byte, error)

func (*Site) ServeHTTP

func (s *Site) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Site) WatchForReloads

func (s *Site) WatchForReloads()

type TemplateParser

type TemplateParser struct{}

func (*TemplateParser) Parse

func (f *TemplateParser) Parse(p *Page) ([]byte, Data, error)

Directories

Path Synopsis
cmd
taragen command

Jump to

Keyboard shortcuts

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