blog

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyBuiltinTheme

func CopyBuiltinTheme(name, destDir string) error

func IsBuiltinTheme

func IsBuiltinTheme(name string) bool

func ListBuiltinThemes

func ListBuiltinThemes() []string

func StartProductionServer added in v0.8.0

func StartProductionServer(cfg ProductionConfig) error

func StopProductionServer added in v0.8.0

func StopProductionServer() error

Types

type Article

type Article struct {
	Title          string            `json:"title"`
	Slug           string            `json:"slug"`
	Published      time.Time         `json:"published"`
	Author         string            `json:"author"`
	Tags           []string          `json:"tags"`
	SEODescription string            `json:"seo_description"`
	OGImage        string            `json:"og_image"`
	AuthorTwitter  string            `json:"author_twitter"`
	Body           template.HTML     `json:"body"`
	Overview       template.HTML     `json:"overview"`
	Data           map[string]string `json:"data"`
	ReadingTime    int               `json:"reading_time"`
	File           string            `json:"file"`
	Dir            string            `json:"dir"`
}

func (Article) FormattedDate

func (a Article) FormattedDate() string

func (Article) ISODate

func (a Article) ISODate() string

func (Article) IsPublished

func (a Article) IsPublished() bool

func (Article) URL

func (a Article) URL() string

type ArticleParser

type ArticleParser struct {
	// contains filtered or unexported fields
}

func NewArticleParser

func NewArticleParser(fsys fs.FS, highlighter *Highlighter, baseURL string) *ArticleParser

func (*ArticleParser) ParseArticle

func (ap *ArticleParser) ParseArticle(ctx context.Context, dir string) (Article, error)

type Author

type Author struct {
	Name    string `yaml:"name"`
	Email   string `yaml:"email"`
	Twitter string `yaml:"twitter"`
}

type Blog

type Blog struct {
	Config      Config
	Articles    []Article
	Highlighter *Highlighter
	// contains filtered or unexported fields
}

func New

func New(root string) (*Blog, error)

func (*Blog) Build

func (b *Blog) Build(ctx context.Context) error

func (*Blog) Discover

func (b *Blog) Discover(ctx context.Context) error

type Config

type Config struct {
	Title       string    `yaml:"title"`
	Description string    `yaml:"description"`
	BaseURL     string    `yaml:"baseURL"`
	Author      Author    `yaml:"author"`
	Theme       string    `yaml:"theme"`
	Highlight   Highlight `yaml:"highlight"`
	SEO         SEOConfig `yaml:"seo"`
	ContentDir  string    `yaml:"contentDir"`
	OutputDir   string    `yaml:"outputDir"`
	ListPages   []string  `yaml:"listPages"`
}

func DefaultConfig

func DefaultConfig() Config

func LoadConfig

func LoadConfig(fsys fs.FS) (Config, error)

func LoadConfigFromPath

func LoadConfigFromPath(path string) (Config, error)

type Highlight

type Highlight struct {
	Style       string `yaml:"style"`
	LineNumbers bool   `yaml:"lineNumbers"`
}

type Highlighter

type Highlighter struct {
	// contains filtered or unexported fields
}

func NewHighlighter

func NewHighlighter(style string, lineNumbers bool) *Highlighter

func (*Highlighter) CSS

func (h *Highlighter) CSS() string

func (*Highlighter) Highlight

func (h *Highlighter) Highlight(code, language string) (string, error)

type PageData

type PageData struct {
	Config       Config
	Article      *Article
	Articles     []Article
	HighlightCSS template.CSS
	CurrentYear  int
	PagePath     string
}

type ProductionConfig added in v0.8.0

type ProductionConfig struct {
	PublicDir string
	Addr      string
}

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

func NewRenderer

func NewRenderer(b *Blog) (*Renderer, error)

func (*Renderer) RenderArticle

func (r *Renderer) RenderArticle(outDir string, article Article) error

func (*Renderer) RenderIndex

func (r *Renderer) RenderIndex(outDir string) error

func (*Renderer) RenderRSS

func (r *Renderer) RenderRSS(outDir string) error

func (*Renderer) RenderRobots

func (r *Renderer) RenderRobots(outDir string) error

func (*Renderer) RenderSitemap

func (r *Renderer) RenderSitemap(outDir string) error

type SEO

type SEO struct {
	Title       string
	Description string
	URL         string
	Image       string
	Type        string
	Author      string
	Published   string
	TwitterCard string
	TwitterSite string
}

func (SEO) JSONLD

func (s SEO) JSONLD() string

func (SEO) OpenGraphTags

func (s SEO) OpenGraphTags() string

func (SEO) TwitterCardTags

func (s SEO) TwitterCardTags() string

type SEOConfig

type SEOConfig struct {
	OGImage     string `yaml:"ogImage"`
	TwitterCard string `yaml:"twitterCard"`
	SiteName    string `yaml:"siteName"`
}

type ThemeInfo

type ThemeInfo struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description"`
	Author      string `yaml:"author"`
	Version     string `yaml:"version"`
	Repository  string `yaml:"repository"`
	Preview     string `yaml:"preview"`
	Path        string `yaml:"-"`
	IsBuiltin   bool   `yaml:"-"`
}

func LoadThemeInfo

func LoadThemeInfo(themeDir string) (ThemeInfo, error)

Jump to

Keyboard shortcuts

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