renderer

package
v0.0.0-...-7635d6e Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsLink(baseURL string, path string) string

AbsLink returns an absolute representation of the given path.

func PageLink(baseURL string, slugifier *slug.Slugifier, page TemplatePage) string

PageLink returns a link for the given page using its slugified title as filename.

func ReplaceExtension

func ReplaceExtension(path, ext string) string

ReplaceExtension replaces the extension of path with ext. The given path remains unchanged if it does not end with a file extension. Note that ext is expected to start with a dot.

Types

type Markdown

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

Markdown renders markdown pages to HTML websites.

func NewMarkdown

func NewMarkdown(md goldmark.Markdown, templates *Templates) *Markdown

NewMarkdown returns an instantiated markdown renderer.

func (*Markdown) FeedPage

func (m *Markdown) FeedPage(ctx context.Context, w io.Writer, page TemplatePage) error

FeedPage renders a page for use in a feed.

func (*Markdown) List

func (m *Markdown) List(
	ctx context.Context,
	w io.Writer,
	content model.Tree,
	siteMenu []model.MenuEntry,
) error

List renders a list, or directory overview, page.

func (*Markdown) Page

func (m *Markdown) Page(
	ctx context.Context,
	w io.Writer,
	page TemplatePage,
	siteMenu []model.MenuEntry,
) error

Page renders a single page.

type TemplateData

type TemplateData struct {
	Title, Description string
	Content            interface{}
	Menu               []model.MenuEntry
}

TemplateData contains data used to render page templates.

type TemplatePage

type TemplatePage struct {
	Path     string
	FM       model.FrontMatter
	Markdown []byte
}

func NewTemplatePage

func NewTemplatePage(page *model.Page) TemplatePage

type Templates

type Templates struct {
	// Page is a template for simple website pages.
	Page *template.Template
	// FeedPage is a template for a page used in a feed.
	FeedPage *template.Template
	// List is a template for list pages, e.g. a list of all blog articles.
	List *template.Template
}

Templates are used by the Renderer to render HTML pages.

func NewTemplates

func NewTemplates(author, baseURL string, slugifier *slug.Slugifier, templateFS fs.FS) *Templates

NewTemplates parses templates from the given fs.FS and provides a set of default template functions. The template folder is expected to contain three files, base.gohtml, page.gohtml and list.gohtml, where base.gohtml will be shared by both, the page and list template.

Jump to

Keyboard shortcuts

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