Documentation
¶
Overview ¶
Package stele contains the top-level types and functions for the stele blog framework.
Index ¶
- func Build(ctx context.Context, srcDir, dstDir string, opts ...BuildOpt) error
- func RenderManifest(ctx context.Context, w io.Writer, cfg *Config) error
- func RenderRSSFeed(ctx context.Context, w io.Writer, cfg *Config, posts Posts) error
- func WithDrafts(cfg *buildConfig)
- type BuildOpt
- type Config
- type Frontmatter
- type MenuLink
- type Page
- type Post
- type PostIndex
- type PostIndexEntry
- type Posts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Build ¶
Build compiles a deployable blog. Source files are read from srcDir and the resulting assets are written to dstDir. The contents of the destination directory, if any, will be deleted when running this function.
func RenderManifest ¶
RenderManifest renders a web manifest to w based on the configuration provided.
func RenderRSSFeed ¶
RenderRSSFeed renders an RSS feed to w based on the configuration and list of posts provided.
func WithDrafts ¶
func WithDrafts(cfg *buildConfig)
Types ¶
type Config ¶
type Config struct { // The author of the blog. Author string `yaml:"author"` // The URL where the blog will be hosted. This is used to construct links // to resources e.g. in the RSS feed and must be an absolute URL including // protocol. BaseURL string `yaml:"baseURL"` // A list of categories that describe the content of the blog. This is used in // the web manifest and RSS feed and should be descriptive without being // overloaded. Categories []string `yaml:"categories"` // A description of the blog's content and/or purpose. Description string `yaml:"description"` // A list of links to include in the top-level site navigation. This is useful // for including links to raw pages e.g. an "about me" page. Menu []MenuLink `yaml:"menu"` // The title/name of the blog. Title string `yaml:"title"` }
Config represents the supported configuration for the stele framework.
type Frontmatter ¶
type Frontmatter struct { // A short description of the post. Description string `yaml:"description"` // Drafts are visible when running the local server, but are not included in // production builds. Draft bool `yaml:"draft"` // A list of tags to associate with the post. Tags []string `yaml:"tags"` // The "authored date" for the post. Timestamp time.Time `yaml:"date"` // The title of the post. Title string `yaml:"title"` }
Frontmatter represents all of the supported frontmatter fields for posts.
type MenuLink ¶
type MenuLink struct { // The text to show the user. Label string `yaml:"label"` // The path for the link. Path string `yaml:"path"` }
MenuLink represents a link that will appear in the main page navigation.
type Page ¶
type Page struct { // The path to the page on disk. Path string // A URL-safe identifier for the page. Slug string }
Page represents a page with static HTML content.
type Post ¶
type Post struct { Frontmatter // The path to the file on disk. Path string // A URL-safe identifier for the post. Slug string }
Post represents a single markdown post.
type PostIndex ¶
type PostIndex []PostIndexEntry
PostIndex is a slice of entries where each entry contains a set of posts that share a common key e.g. post year, tag, etc.
type PostIndexEntry ¶
PostIndexEntry represents a collection of posts that shared a common key e.g. post year, tag, etc.
type Posts ¶
type Posts []Post
Posts is an alias for a slice of Post objects.
func NewPosts ¶
NewPosts returns a slice of Posts by parsing the contents of the provided directory.
func (Posts) ByTag ¶
ByTag returns an index of posts grouped by common tags. A post with multiple tags will appear in multiple entries in the index.
func (Posts) ByYear ¶
ByYear returns an index of posts grouped by the year they were authored. A given post will only appear in one entry in the index.
func (Posts) First ¶
First returns the earliest post by authored date. This method assumes that the posts are sorted in descending order by timestamp.
func (Posts) Head ¶
Head returns the first posts in the slice and a Posts object containing the remaining posts. If there is only one post, the second return value will be nil. If there are no posts, both return values will be nil.
func (Posts) MostRecent ¶
MostRecent returns the n most recent posts. If n > len(ps), it will return all of the posts.
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
internal
|
|
markdown
Package markdown contains thin wrappers around third-party markdown implementations.
|
Package markdown contains thin wrappers around third-party markdown implementations. |
Package template contains template definitions for the default stele blog pages.
|
Package template contains template definitions for the default stele blog pages. |
components
Package components contains templates for components used on multiple pages.
|
Package components contains templates for components used on multiple pages. |
components/icons
Package icons contains components that render SVG icons.
|
Package icons contains components that render SVG icons. |
pages
Package pages contains templates for individual pages in a rendered blog.
|
Package pages contains templates for individual pages in a rendered blog. |