data

package
v2.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package data 对加载的数据进行二次加工

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildURL

func BuildURL(baseURL string, p ...string) string

BuildURL 将 p 添加到 baseURL 形成一条完整的 URL

Types

type Archive

type Archive struct {
	Title string  // 当前存档页的标题
	Posts []*Post // 当前存档的文章列表
	// contains filtered or unexported fields
}

Archive 单个存档项

type Archives

type Archives struct {
	Title       string
	Permalink   string
	Keywords    string
	Description string
	Archives    []*Archive
}

Archives 存档的相关信息

type Data

type Data struct {
	URL         string
	Title       string
	Subtitle    string
	TitleSuffix string // 每篇文章标题的后缀
	Icon        *loader.Icon
	Language    string
	Author      *loader.Author
	License     *loader.Link
	Theme       *Theme
	Highlights  []*Highlight
	Menus       []*loader.Link

	RSS     *RSS
	Atom    *RSS
	Sitemap *Sitemap
	Robots  *Robots
	Profile *Profile

	Uptime   time.Time
	Created  time.Time
	Modified time.Time
	Builded  time.Time // 最后次编译时间

	Tags     *Tags
	Posts    []*Post
	Indexes  []*Index
	Archives *Archives
}

Data 处理后的数据

func Load

func Load(fs fs.FS, preview bool, baseURL string) (*Data, error)

Load 加载并处理数据

preview 表示是否为预览模式,在预览模式下会加载草稿同; 如果 baseURL 不为空,则会替换配置文件中的 URL 字段。

type Highlight

type Highlight struct {
	Name  string // 主题名称
	Path  string
	URL   string
	Media string
}

Highlight 高亮主题

type Index

type Index struct {
	Title       string
	Permalink   string
	Keywords    string
	Description string
	Posts       []*Post
	Index       int // 当前页的索引
	Path        string
	Next        *Index
	Prev        *Index
}

Index 索引页内容

type Post

type Post struct {
	Permalink string
	Slug      string
	Path      string
	Title     string
	Created   time.Time
	Modified  time.Time
	Tags      []*Tag

	Language string
	Authors  []*loader.Author
	License  *loader.Link
	Keywords string
	Summary  string
	Content  string
	Image    string
	Prev     *Post
	Next     *Post
	Template string
	JSONLD   string
	TOC      []loader.Header
	// contains filtered or unexported fields
}

Post 文章详情

type Profile

type Profile struct {
	Path   string
	Title  string
	Footer string
	Posts  []*Post
}

Profile github.com 下与账号同名仓库的 README.md 文件管理

type RSS

type RSS struct {
	Title        string
	Permalink    string
	XSLPermalink string
	Path         string
	Posts        []*Post
}

RSS 整理后的 RSS 和 Atom 数据

type Robots

type Robots struct {
	Path     string
	Sitemaps []string
	Agents   []*loader.Agent
}

Robots robots.txt 的相关内容

type Sitemap

type Sitemap struct {
	*loader.Sitemap
	Permalink    string
	XSLPermalink string
	Path         string
}

Sitemap 的相关配置项

type Tag

type Tag struct {
	Permalink string
	Slug      string
	Path      string
	Title     string
	Keywords  string
	Content   string // 对该标签的详细描述
	Posts     []*Post
	Prev      *Tag
	Next      *Tag
	Created   time.Time
	Modified  time.Time
}

Tag 单个标签的内容

type Tags

type Tags struct {
	Title       string
	Permalink   string
	Keywords    string
	Description string
	Tags        []*Tag
}

Tags 标签列表及相关设置项

type Theme

type Theme struct {
	ID          string
	URL         string
	Description string
	Authors     []*loader.Author
}

Theme 主题描述

Jump to

Keyboard shortcuts

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