article

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SEP_META              = "---"
	SEP_MORE              = "<!--more-->"
	SEP_OUTLINE           = "<!--outline-->"
	SEP_SAFE_MODE         = "<!-- raw HTML omitted -->"
	EXT_MARKDOWN          = ".md"
	EXT_RESTRUCTURED_TEXT = ".rst"
)
View Source
const (
	DefaultDirMode  = 0755
	DefaultFileMode = 0666
	DefaultTheme    = "default"
)

Variables

This section is empty.

Functions

func AddUrlPre

func AddUrlPre(dir string) string

func I18n

func I18n(val string) string

Types

type Article

type Article struct {
	Meta    *MetaData
	Author  *User
	Archive *Link
	Format  string
	Source  string
	Content string
	Outline string
}

func NewArticle

func NewArticle() *Article

func (*Article) ParseFile

func (a *Article) ParseFile(path string) (string, error)

func (*Article) SetData

func (a *Article) SetData(name string, chunk []byte) int

func (*Article) SetDirUrl

func (a *Article) SetDirUrl(dir, url string) *Link

func (*Article) SetDummyAuthor

func (a *Article) SetDummyAuthor(id string) *User

func (*Article) SetFormat

func (a *Article) SetFormat(ext string)

func (*Article) SplitContent

func (a *Article) SplitContent(data []byte) error

func (*Article) SplitSource

func (a *Article) SplitSource(data []byte, times int) error

type Catelog

type Catelog struct {
	Site  *Website
	Node  *list.Element
	Start int
	Stop  int
}

func CreateCatelogs

func CreateCatelogs(count, pageSize int) []*Catelog

func (Catelog) GetArchives

func (c Catelog) GetArchives() []*Link

func (Catelog) GetNext

func (c Catelog) GetNext() string

func (Catelog) GetPrev

func (c Catelog) GetPrev() string
type Footer struct {
	Copyright  string
	From_year  int
	Curr_year  int
	Cn_cert_no string
}
type Link struct {
	Dir    string
	Url    string
	Anchor string
	Title  string
	Note   string
}

func (Link) ToString

func (l Link) ToString(urlpre string) string

type MetaData

type MetaData struct {
	Title  string   `yaml:"title"`
	Slug   string   `yaml:"slug,omitempty"`
	Date   string   `yaml:"date,omitempty"`
	Update string   `yaml:"update,omitempty"`
	Author string   `yaml:"author,omitempty"`
	Tags   []string `yaml:"tags,omitempty"`
	Draft  bool     `yaml:"draft,omitempty"`
	Weight int      `yaml:"weight,omitempty"`
}

type Setting

type Setting struct {
	Title    string
	Lang     string
	Source   string
	Public   string
	Theme    string
	Port     uint
	Limit    int
	Sort     string
	Show_toc bool
	Top_tags []string
	Github   string
	Authors  map[string]*User
	Footer   *Footer
	Layout   *Table
}

func NewSetting

func NewSetting() *Setting

func (*Setting) GetFooter

func (s *Setting) GetFooter() *Footer

func (*Setting) GetTheme

func (s *Setting) GetTheme() string

type Table

type Table map[string]any

type Theme

type Theme struct {
	PubDir   string // 结尾有斜杠
	FunDict  template.FuncMap
	TplDict  map[string]*template.Template
	WithSide bool
	// contains filtered or unexported fields
}

func NewTheme

func NewTheme(dir string) *Theme

func (Theme) CopyAssets

func (t Theme) CopyAssets(dir string) (err error)

func (Theme) CreateSidebar

func (t Theme) CreateSidebar(path string, archDirs map[string][]string) (err error)

func (Theme) GetDir

func (t Theme) GetDir() string

func (*Theme) GetOrCreate

func (t *Theme) GetOrCreate(name, path string, incl bool) *template.Template

func (*Theme) HasTemplate

func (t *Theme) HasTemplate(name string) bool

func (*Theme) Render

func (t *Theme) Render(name, path string, cxt Table) (err error)

type User

type User struct {
	ID     string
	Name   string
	Intro  string
	Avatar string
}

type Website

type Website struct {
	Root       string
	DirList    []string
	DirLinks   map[string][]string
	TagIndexes map[string][]int
	Articles   []*Article
	Conf       *Setting
	Skin       *Theme
	Convert    func(source []byte, format string) []byte
	Debug      func(data ...any)
}

func NewWebsite

func NewWebsite(root string) *Website

func (*Website) AddArticle

func (w *Website) AddArticle(blog *Article, dir string) error

func (*Website) BuildFiles

func (w *Website) BuildFiles() error

func (Website) CreateDirs

func (w Website) CreateDirs() error

func (*Website) CreateIndex

func (w *Website) CreateIndex(pageSize int) (err error)

func (Website) CreatePages

func (w Website) CreatePages(thDir string, thPrelen int) (err error)

func (Website) CreateTags

func (w Website) CreateTags() (err error)

func (*Website) CreateWalkFunc

func (w *Website) CreateWalkFunc() filepath.WalkFunc

func (Website) GetTagArchives

func (w Website) GetTagArchives(name string) []*Link

func (Website) GlobPages

func (w Website) GlobPages(thDir string) ([]string, error)

func (*Website) InitTheme

func (w *Website) InitTheme() error

func (*Website) LoadConfig

func (w *Website) LoadConfig(path string) error

func (Website) Prepare

func (w Website) Prepare(dir string, cxt Table, createDir bool) (err error)

func (*Website) ProcFile

func (w *Website) ProcFile(fullpath, path string) (*Article, error)

func (*Website) RenderBlog

func (w *Website) RenderBlog(tpl string, blog *Article) error

func (*Website) SortByDate

func (w *Website) SortByDate()

Jump to

Keyboard shortcuts

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