Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Blog ¶
type Blog []Post
Blog is just a collection of Posts.
func (Blog) PostsByDate ¶
PostsByDate returns Posts of the Blog sorted in ascending or descending order (if asc == false). If includeDrafts == true draft Posts are also included. If withTags is present only Posts having the tags are included.
type MarkdownBlog ¶
type MarkdownBlog struct {
// contains filtered or unexported fields
}
MarkdownBlog represents a Blog stored as Markdown files in a directory.
Posts are stored as Markdown files in the posts subdirectory of the Blog directory. Draft Posts (ones with Draft set to true) are stored in the draft subdirectory of the posts directory.
So the structure looks like this:
blog/ posts/ draft/ draft1.md ... post1.md post2.md ...
Markdown files have the following format:
# Title *Jan 2, 2009* *tag1, tag2, ...* Content
func NewMarkdownBlog ¶
func NewMarkdownBlog(dir string) MarkdownBlog
NewMarkdownBlog creates a MarkdownBlog in the provided directory.
If the directory doesn't exist it creates it.
func (MarkdownBlog) Read ¶
func (b MarkdownBlog) Read() (Blog, error)
Read creates a Blog from the Markdown files.
If the directory doesn't exist it returns an error.
type Post ¶
type Post struct { Title string // Content of the post (can use Markdown). Content string Written time.Time Tags []string Draft bool }
Post is a Blog's post.
type ProgressFunc ¶
type ProgressFunc func(path string)
ProgressFunc is used to monitor progress of generating a Blog. It is called before a file generation is started.
type StaticBlogGenerator ¶
type StaticBlogGenerator struct {
// contains filtered or unexported fields
}
StaticBlogGenerator generates Blogs to static HTML files.
func NewStaticBlogGenerator ¶
func NewStaticBlogGenerator(blog Blog, templatesDir, outputDir string, progressFunc ProgressFunc) (StaticBlogGenerator, error)
NewStaticBlogGenerator creates a StaticBlogGenerator that generates the Blog to static HTML files in the outputDir using templates from the templatesDir. It calls the progressFunc before generating each file.
func (StaticBlogGenerator) Generate ¶
func (g StaticBlogGenerator) Generate() error
Generate generates a Blog to static HTML files.