lib

package
v0.0.0-...-ddfb969 Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: MIT Imports: 10 Imported by: 0

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) Len

func (b Blog) Len() int

func (Blog) Less

func (b Blog) Less(i, j int) bool

func (Blog) PostsByDate

func (b Blog) PostsByDate(asc, includeDrafts bool, withTags ...string) []Post

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.

func (Blog) Swap

func (b Blog) Swap(i, j int)

func (Blog) Tags

func (b Blog) Tags(lookInDrafts bool) []string

Tags returns all tags used in Posts of the Blog. If lookInDrafts == true draft Posts are also checked.

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.

Jump to

Keyboard shortcuts

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