compile

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile

func Compile(in string, serviceWorker bool)

func FriendlyName

func FriendlyName(p string) string

func RenameFolder

func RenameFolder(in string, out string)

Types

type Builder

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

func NewBuilder

func NewBuilder(src []byte) *Builder

func (*Builder) AddCart

func (d *Builder) AddCart(f *FrontMatter) string

func (*Builder) LessonSorter

func (d *Builder) LessonSorter(pg *CompiledDocument) string

func (*Builder) Page

func (d *Builder) Page(title, content string, loader string, back bool) string

type CompiledDocument

type CompiledDocument struct {
	*FrontMatter

	// these can be discarded after building the document to save memory.
	Contents Lesson
	Lesson   []Lesson
}

type CompiledFolder

type CompiledFolder struct {
	Name string
	IndexJson
	Document []*FrontMatter
	Folder   []*CompiledFolder
}

type FrontMatter

type FrontMatter struct {
	Id       string   `yaml:"id"`
	Version  int      `yaml:"version"`
	Title    string   `yaml:"title"` // this is the name of the folder and its sort key
	Subtitle string   `yaml:"subtitle"`
	Sort     string   `yaml:"sort"`
	Image    string   `yaml:"image"`
	Link     string   `yaml:"link"` // not loaded, computed after a load
	MinGrade int      `yaml:"minGrade"`
	MaxGrade int      `yaml:"maxGrade"`
	IronShop []string `yaml:"ironShop"`
	Cart     int      `yaml:"cart"`
	// contains filtered or unexported fields
}

type IndexJson

type IndexJson struct {
	Id       string      `json:"id,omitempty" yaml:"id"`
	Version  int         `json:"version,omitempty" yaml:"version"`
	Title    string      `json:"title,omitempty" yaml:"title"` // this is the name of the folder and its sort key
	Sort     string      `json:"sort,omitempty"`
	Image    string      `json:"image,omitempty" yaml:"sort"`
	Link     string      `json:"link,omitempty"`  // not loaded, computed after a load
	Union    []string    `json:"union,omitempty"` // union all these (probably hidden) folders
	Hidden   bool        `json:"hidden,omitempty"`
	Pin      []*LinkInfo `json:"pin,omitempty"`
	Template string      `json:"template,omitempty"`
}

the front matter from a folder comes from index.json

type Lesson

type Lesson struct {
	Number int
	Slide  []string
	Link   string
}

if we need it the lesson title is on the first slide #

type LinkInfo

type LinkInfo struct {
	Title   string `json:"title,omitempty"`
	Sort    string `json:"sort,omitempty"`
	Image   string `json:"image,omitempty"` // just ignored? we are using the image from the linked from, this could be default though.
	Path    string `json:"path,omitempty"`
	Folder  bool   `json:"folder,omitempty"`
	Content string `json:"content,omitempty"`
}

type PageInfo

type PageInfo struct {
	Title,
	Content string
	Loader string
	Back   bool
}

type WalkState

type WalkState struct {
	Out string
	In  string

	// asset maps the name of the asset to the link
	Asset         map[string]string
	NextAsset     int
	ServiceWorker bool

	Folder map[string]*CompiledFolder
}

Jump to

Keyboard shortcuts

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