view

package
v0.0.0-...-d28c92d Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StripFrontMatter

func StripFrontMatter(content []byte) []byte

StripFrontMatter removes YAML front matter from content and returns just the body

Types

type IndexData

type IndexData struct {
	Title       string          `json:"title"`
	Description string          `json:"description"`
	OGImage     string          `json:"ogImage"`
	Articles    []model.Article `json:"articles"`
	Total       int             `json:"total"`
}

IndexData holds the data required for rendering the index page

func (*IndexData) Map

func (d *IndexData) Map() map[string]any

Map converts IndexData to a map[string]any

type PostData

type PostData struct {
	Slug        string
	Title       string
	Description string
	OgImage     string
	Content     string
	Date        *time.Time
	Classnames  string
}

PostData holds the data required for rendering the post layout

func (*PostData) Map

func (d *PostData) Map() map[string]any

Map converts PostData to a map[string]any

type Views

type Views struct {
	*layout.Renderer
	// contains filtered or unexported fields
}

func NewViews

func NewViews(root fs.FS) (*Views, error)

func (*Views) AtomFeed

func (v *Views) AtomFeed(ctx context.Context, w io.Writer, articles []model.Article) error

AtomFeed generates an Atom XML feed for articles

func (*Views) Blog

func (v *Views) Blog(ctx context.Context, w io.Writer, data *IndexData) error

Blog renders the blog list page

func (*Views) Index

func (v *Views) Index(ctx context.Context, w io.Writer, data *IndexData) error

Index renders the blog index/list page

func (*Views) IndexFromArticles

func (v *Views) IndexFromArticles(articles []model.Article) *IndexData

IndexFromArticles creates IndexData from a list of articles

func (*Views) Post

func (v *Views) Post(ctx context.Context, w io.Writer, data *PostData) error

Post renders the post layout template

func (*Views) PostFromArticle

func (v *Views) PostFromArticle(article *model.Article, content string) *PostData

PostFromArticle creates PostData from an Article

Jump to

Keyboard shortcuts

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