content

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: GPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(c []byte) []byte

Parse markdown formatted content (c) to html Returns byte-array of html content

Types

type Blurb

type Blurb struct {
	Title   string
	Summary template.HTML
	Date    string
	Tags    []string
	Slug    string
}

type Content

type Content struct {
	Title       *string `yaml:"title"`
	Summary     *string `yaml:"summary"`
	Path        *string
	Published   *bool   `yaml:"published"`
	PublishDate *string `yaml:"date"`
	Tags        *string `yaml:"tags"`
	Body        []byte
}

func GetAll

func GetAll(subDirs ...string) ([]Content, error)

Get all content from a directory in env.CONTENT_DIR. If no sub-directories are given will get all content in env.CONTENT_DIR.

@params

nil - get all content from env.CONTENT_DIR and its sub-directories
subDirs []string - sub-directories in env.CONTENT_DIR to get content from

@return

[]Content - Content objects for each file in subdirs
error - problem reading directory, returns all entries it could read up until error

func NewPage

func NewPage(path string) (*Content, error)

Parse a pages markdown file as a Content object. Markdown is transpiled to HTML and stored as []byte.

@params

path string - path to the content file to parse, relative to env.CONTENT_DIR

@return

*Content - on successful parsing of Content
error - if file cannot be found or metadata cannot be parsed

func NewPost

func NewPost(path string) (*Content, error)

Parse a posts markdown file as a Content object. Markdown is transpiled to HTML and stored as []byte.

@params

path string - path to the content file to parse, relative to env.CONTENT_DIR

@return

*Content - on successful parsing of Content
error - if file cannot be found or metadata cannot be parsed

func (*Content) Blurb

func (c *Content) Blurb() *Blurb

Creates a Blurb from a Content Parses md to html and wraps in a Blurb

Jump to

Keyboard shortcuts

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