site

package
v0.0.0-...-5a8f55b Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: MIT, Unlicense Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	BaseURL string

	Content   fs.FS
	Templates fs.FS
	Includes  fs.FS
	Files     fs.FS
	Fallback  http.HandlerFunc
}

func (Config) Parse

func (config Config) Parse() (*Site, error)
type ExternalLink struct {
	Title string `yaml:"title"`
	URL   string `yaml:"url"`
}

type FrontMatter

type FrontMatter struct {
	Slug       string     `yaml:"url"`
	Title      string     `yaml:"title"`
	Subtitle   string     `yaml:"subtitle"`
	ShortTitle string     `yaml:"shorttitle"`
	Date       *time.Time `yaml:"date"`

	After  string `yaml:"after"`
	Before string `yaml:"before"`

	HideChildren   bool     `yaml:"hidechildren"`
	ChildrenNoLink bool     `yaml:"childrennolink"`
	Children       []string `yaml:"children"`

	RSS bool `yaml:"rss"`

	Images []Image        `yaml:"images"`
	Links  []ExternalLink `yaml:"links"`
}

FrontMatter is used to define properties for the page.

func (FrontMatter) URL

func (fm FrontMatter) URL() string

type Image

type Image struct {
	Alt    string `yaml:"alt"`
	Source string `yaml:"source"`
}
type InternalLink struct {
	Level     int
	Title     string
	HeadingID string
}
type Nav struct {
	Page     *Page
	Active   bool
	Children []Nav
}

type Page

type Page struct {
	FrontMatter
	TOC []InternalLink

	Template string

	Summary     string
	Content     template.HTML
	Rendered    []byte
	RenderedRSS []byte

	Parent   *Page
	Before   *Page
	After    *Page
	Children []*Page
}

func ParseMarkdown

func ParseMarkdown(includes fs.FS, path string, content []byte) (*Page, error)

func ParseTemplate

func ParseTemplate(includes fs.FS, path string, content []byte) (*Page, error)

type PageData

type PageData struct {
	Nav   Nav
	Front *FrontMatter
	*Page
}

type RSSChannel

type RSSChannel struct {
	XMLName     xml.Name  `xml:"channel"`
	Title       string    `xml:"title"`
	Link        string    `xml:"link"`
	Description string    `xml:"description"`
	Items       []RSSItem `xml:"item"`
}

type RSSItem

type RSSItem struct {
	XMLName     xml.Name `xml:"item"`
	Title       string   `xml:"title"`
	Link        string   `xml:"link"`
	Description string   `xml:"description"`
	PubDate     string   `xml:"pubDate,omitempty"`
}

type RSSXML

type RSSXML struct {
	XMLName  xml.Name     `xml:"rss"`
	Version  string       `xml:"version,attr"`
	Channels []RSSChannel `xml:"channel"`
}

type Site

type Site struct {
	BaseURL string

	// Pages are indexed without prefixed "/".
	Pages        map[string]*Page
	Template     *template.Template
	BaseTemplate *template.Template
	Content      fs.FS
	Files        fs.FS
	Fallback     http.HandlerFunc
}

func (*Site) ServeHTTP

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

Jump to

Keyboard shortcuts

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