view

package
v0.0.0-...-09dfd77 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLayoutTemplate []byte

Functions

This section is empty.

Types

type Context

type Context struct {
	Contents template.HTML
	// Configurable Attributes
	Links     []*NavLink
	Theme     string
	DocTitle  string
	PageTitle string
}

Template Context

type NavLink struct {
	Name string
	Path string
}

type View

type View struct {
	Path     string
	Markdown *md.MD
	HTML     []byte

	Templ *template.Template
	Links []*NavLink
	// contains filtered or unexported fields
}

func NewViews

func NewViews(contentDir, templateDir string) ([]*View, error)

func WithNavigation

func WithNavigation(views []*View) []*View

function WithNavigation populates a NavLink list in the View struct to build context when rendering the layout

func (*View) BuildHTMLFileContents

func (v *View) BuildHTMLFileContents(c *config.Config) (string, error)

func (*View) GetTemplate

func (v *View) GetTemplate() error

function getTemplate checks for the presence of a template dir, then for the following patterns before following back to the default embedded above

  1. {template_dir}/{layout}.html
  2. {template_dir}/{name}.html
  3. {template_dir}/base.html
  4. DefaultLayoutTemplate (/cmd/build/views/base.html)

func (View) Handler

func (v View) Handler(logger *log.Logger) http.HandlerFunc

func (View) Name

func (v View) Name() string

func (*View) Render

func (v *View) Render(w io.Writer, conf *config.Config) error

func Render executes and writes the template with included frontmatter

Jump to

Keyboard shortcuts

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