content

package
v0.0.0-...-db2f016 Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ST_POST = iota
	ST_SERIES
)
View Source
const IsoDateFormat = "2006-01-02"

Variables

This section is empty.

Functions

This section is empty.

Types

type Post

type Post struct {
	Date        time.Time
	ContentPath string
	Metadata    PostMetadata
	Name        string
	Series      *Series
	Title       string
}

A Post is a dated page.

func NewPost

func NewPost(dateStr, name, contentPath, metadataPath string, series *Series) (*Post, error)

func (*Post) HTML

func (p *Post) HTML() (template.HTML, error)

func (*Post) RelativeURL

func (p *Post) RelativeURL() string

func (*Post) TitleWithSeries

func (p *Post) TitleWithSeries() string

type PostIndex

type PostIndex struct {
	Posts  []*Post
	Series []*Series
	// contains filtered or unexported fields
}

func NewPostIndex

func NewPostIndex(contentDir string) (*PostIndex, error)

Loads posts from a directory into a PostIndex.

func (*PostIndex) Get

func (p *PostIndex) Get(series, name string) *Post

func (*PostIndex) GetBaseSeries

func (p *PostIndex) GetBaseSeries() *Series

Returns the base (unnamed) series. For now, that's all the random-access we need.

func (*PostIndex) GetLatest

func (p *PostIndex) GetLatest() *Post

Returns the most recent post of all series.

func (*PostIndex) GetPriorPosts

func (p *PostIndex) GetPriorPosts(seriesName string) []*Post

Returns all posts in a series, newest first, but excluding the newest post if it's the newest one in all series.

type PostMetadata

type PostMetadata struct {
	Tags []string `json:"tags"`
	Deck string   `json:"deck"` // the "deck" or "drop line" of the post
}

Extra metadata about a post.

type Series

type Series struct {
	SeriesMetadata
	Name  string
	Posts []*Post
}

func NewSeries

func NewSeries(name, metadataPath string) (*Series, error)

type SeriesAuthor

type SeriesAuthor struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

type SeriesMetadata

type SeriesMetadata struct {
	Title string `json:"title"`
	// Fields required for RSS but otherwise optional.
	// Usually these will only be set for the base (unnamed) series.
	Description string       `json:"description"`
	Author      SeriesAuthor `json:"author"`
	Created     time.Time    `json:"created,string"`
}

Jump to

Keyboard shortcuts

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