chca

package module
v0.0.0-...-dab2878 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

README

CHCA

chca是一个使用golang开发的静态博客生成器,简单、方便、快捷,抛弃每次都需要使用命令编译文件,采用文件监听方式编译,博客作者只需把markdown文件放到配置中的markdown文件夹下就能自动生成html了。

安装

go get -v github.com/num5/chca

或者下载安装

https://github.com/num5/chca/releases

使用

# chca command [args...]

# 初始化博客文件夹
    chca init

# 新建 markdown 文件
    chca new filename

# 编译博客
    chca compile/c
    
# 打开文件监听器
    chca watch/w

# 打开文件服务器, 默认端口9900
    chca http [port]
    
# 运行chca, 默认端口9900
    chca run [port]
chca init

chca init 用于初始化博客,会自动生成config.yml

# config.yml

# 站点信息
title: 我的网站
subtitle: 网站标题
description: mate-description
keywords: mate-keywords
summary_line: 10 // 首页文章行数
home_art_num: 30 // 首页文章数量

# 文件夹相关
theme: theme/blog //网站模板
markdown: markdown //博客markdown文件存放文件夹
html: /data/www/html //博客html文件存放文件夹
storage: storage //数据存放文件夹,暂时未用到

# 作者信息
author: your name
avatar: /assets/avatar.png  //头像连接,一般放到assets或者avatar文件夹里
github: https://github.com/num5  //github主页
weibo: http://weibo.com/golune  //微博主页
mail: 378999587@qq.com  //email 地址
zhihu: https://www.zhihu.com/people/golune  //知乎主页
 
# 监听信息
paths:  // 监听文件夹
  - markdown
exts:  // 监听后缀名
  - md

# 上传信息
upload_theme: theme/upload  // 上传模版地址

# 自定义标题,可不配置,使用chca设置好的标题
home_title: 主页标题
archive_title: 文章归档标题
tag_title: 标签导航页面标题
cate_title: 分类导航页面标题
about_title: 简历页面标题
article_title: 文章标题标头

初始化以后需要在config.yml文件同目录下创建theme文件夹用于存放模板文件

模板文件夹结构

  • blog 模版文件夹
  • -- assets 资源文件夹
  • -- -- css
  • -- -- js
  • -- layout 布局文件夹
  • -- -- main.html 公共布局
  • -- -- index.html 主页
  • -- -- post.html 文章页
  • -- -- archive.html 归档导航页
  • -- -- category.html 分类导航页
  • -- -- tag.html 标签导航页
  • -- -- page.html 标签和分类列表页面

模板语法参照:template

chca new filename

新建markdown文件

markdown文件需要以 --- 开头进行说明:


---
date: 2017-01-01
title: 我的博客
categories:
- 技术
tags:
- golang
---

建议使用chca创建markdown文件

about.md文件是存放作者简历的文件,存放在markdown文件夹 另外readme.mdabout.md不会被文章解析器解析

chca compile

生成html文件

chca watch/w

开启文件监听器,监听文件夹和文件后缀名在config.yml里配置,配置示例:

// 监听文件夹
paths:
  - markdown
 
// 监听后缀名
exts:
  - md  // 监听 markdown 文件(以.md为后缀的文件)

以上配置:监听器监听markdown文件夹下的以.md为后缀的文件,当文件夹下的.md文件新增或者发生改变时,chca则会自动编译博客

chca http 8800

打开内部服务器,监听端口8800

chca run 8800

打开内部服务器,监听端口8800,并开启文件监听器

License

etcd is under the Apache 2.0 license. See the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile

func Compile()

func CompileAbout

func CompileAbout()

编译about页

func CompileArchive

func CompileArchive()

编译归档页

func CompileArticle

func CompileArticle()

编译文章页

func CompileCatePage

func CompileCatePage()

编译cate导航页

func CompileCategory

func CompileCategory()

编译category页面

func CompileHome

func CompileHome()

编译主页

func CompileTag

func CompileTag()

编译tag页面

func CompileTagPage

func CompileTagPage()

编译tag导航页

func CrearteMark

func CrearteMark(filename string) string
func CreatePostLink(art *Article) string

配置生产路径

func Exist

func Exist(filename string) bool

func GetCate

func GetCate() map[string]*Category

获取菜单数组

func GetTag

func GetTag() map[string]*Tag

获取tag

func Initialize

func Initialize()

func ListenHttpServer

func ListenHttpServer(port int)

func LoadArticle

func LoadArticle()

func Marklist

func Marklist() (mdlist []string)

获取 markdown 文件夹下所有文件

func ReadMuCtx

func ReadMuCtx(path string) (ctx *mustring, err error)

Types

type Article

type Article struct {
	Id          int    `json:"id"`
	Title       string `json:"title"`
	Description string `json:"description"`

	Content  string   `json:"content"`
	Summary  string   `json:"summary"`
	Tags     []string `json:"tags"`
	Category []string `json:"cate"`

	CreatedAt int64  `json:"created_at"`
	UpdatedAt int64  `json:"updated_at"`
	Url       string `json:"url"`
}

func GetAbout

func GetAbout() (art *Article, err error)

获取about内容

func GetAllArt

func GetAllArt() []*Article

获取所有的文章

func GetHomeArt

func GetHomeArt() []*Article

获取首页文章

type Articles

type Articles []*Article

func (Articles) Len

func (a Articles) Len() int

func (Articles) Less

func (a Articles) Less(i, j int) bool

func (Articles) Swap

func (a Articles) Swap(i, j int)

type Category

type Category struct {
	Count int        `json:"count"`
	Name  string     `json:"name"`
	Posts []*Article `json:"posts"`
	Url   string     `json:"url"`
}

type CollatedMonth

type CollatedMonth struct {
	Month string     `json:"month"`
	Posts []*Article `json:"posts"`
	// contains filtered or unexported fields
}

type CollatedMonths

type CollatedMonths []*CollatedMonth

func (CollatedMonths) Len

func (c CollatedMonths) Len() int

func (CollatedMonths) Less

func (c CollatedMonths) Less(i, j int) bool

func (CollatedMonths) Swap

func (c CollatedMonths) Swap(i, j int)

type CollatedYear

type CollatedYear struct {
	Year   string           `json:"year"`
	Months []*CollatedMonth `json:"months"`
	// contains filtered or unexported fields
}

func GetArchive

func GetArchive() []*CollatedYear

获取归档信息

type CollatedYears

type CollatedYears []*CollatedYear

func (CollatedYears) Len

func (c CollatedYears) Len() int

func (CollatedYears) Less

func (c CollatedYears) Less(i, j int) bool

func (CollatedYears) Swap

func (c CollatedYears) Swap(i, j int)

type FileHandler

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

func (*FileHandler) Http

func (fh *FileHandler) Http()

type Tag

type Tag struct {
	Count int        `json:"count"`
	Name  string     `json:"name"`
	Posts []*Article `json:"posts"`
	Url   string     `json:"url"`
}

type Watch

type Watch struct {
	Paths []string
	Exts  []string
}

func NewWatch

func NewWatch(paths []string, exts []string) *Watch

func (*Watch) Watcher

func (w *Watch) Watcher()

type Website

type Website struct {
	Title       string `yaml:"title"`
	SubTitle    string `yaml:"subtitle"`
	Description string `yaml:"description"`
	Keywords    string `yaml:"keywords"`
	SummaryLine int    `yaml:"summary_line"`
	HomeArtNum  int    `yaml:"home_art_num"`

	Theme    string `yaml:"theme"`
	Markdown string `yaml:"markdown"`
	Html     string `yaml:"html"`
	Storage  string `yaml:"storage"`

	Author string `yaml:"name"`
	Avatar string `yaml:"avatar"`
	Github string `yaml:"github"`
	Weibo  string `yaml:"weibo"`
	Mail   string `yaml:"mail"`
	Zhihu  string `yaml:"zhihu"`

	Paths []string `yaml:"paths"`
	Exts  []string `yaml:"exts"`

	UploadTheme string `yaml:"upload_theme,omitempty"`

	HomeTitle    string `yaml:"home_title,omitempty"`
	ArchiveTitle string `yaml:"archive_title,omitempty"`
	TagTitle     string `yaml:"tag_title,omitempty"`
	CateTitle    string `yaml:"cate_title,omitempty"`
	AboutTitle   string `yaml:"about_title,omitempty"`
	ArticleTitle string `yaml:"article_title,omitempty"`
}

func Config

func Config() Website

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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