# Maverick
[![][image-1]][1] [![Build Status][image-2]][2] ![][image-3]
## Overview | 概述
Maverick 是一个基于 Python 构建的静态博客生成器。类似 Hexo和 Jekyll, 使用 Markdown (`.md`) 文件作为输入源, 输出格式优美、结构良好的静态网站页面
(`.html`). 它内置许多有用的特性(feed, search, sitemap, etc.), 支持增强的 Markdown 语法,增加内置的图像处理.
如果您对复杂的插件和复杂的配置感到厌倦,只需尝试一下Maverick。 您可以专注于写作,让Maverick负责其余的工作。
欢迎提交 Pull requests。如果你有一些问题和建议,请前往 [issue area][3] 给我们留言。 提问之前,请先阅读完本文档。
## Usage | 使用
Maverick是使用现代Python构建的,目前至少需要** Python 3.5 **,请确保已将其安装在计算机上。
### Install | 安装
克隆仓库:
```bash
git clone https://github.com/AlanDecode/Maverick.git ./Maverick && cd ./Maverick
```
安装依赖:
```bash
pip install -r requirements.txt
```
如果出现错误,请验证你 Python 和 pip 的版本。然后编辑默认的配置文件:
```bash
vi ./demo_src/config.py
```
现在,让我们使用默认设置。 在终端中键入以下命令:
```bash
python3 mvrk.py --config ./demo_src/config.py --source_dir ./demo_src/ --build_dir ./dist/
```
...在 `dist` 文件夹中生成了一个示例静态站点! 你可以把它们上传到 GitHub Pages 或者其他的服务器。
### Generate your own site | 生成自己的网站
默认情况下, Maverick 递归搜索 `demo_src` 文件夹下所有的 `.md` 文件, 所以将你的 Markdown 文件放在这里然后运行上面的命令。 静态网页文件将在 `dist` 文件夹中生成。 Maverick 使用被称为 `YAML frontmatter` 来获得文章元数据,如果你使用过 Hexo 或者 Jekyll, 你应当非常熟悉他们;如果你对他们不熟悉,请继续往下看。
## File arrangement and `frontmatter`
在 Maverick 中,File arrangement 在你的源文件中并不重要,您可以按类别,日期或任何您喜欢的东西进行排列,Maverick会尝试自动查找它们。
取而代之的是,每个 Markdown 文件的 `frontmatter` 告诉Maverick它的 slug,类别,标签和发布日期等。`frontmatter` 是每个Markdown文件顶部的一小段文字,如下所示:
```
---
layout: post
title: A interesting story
slug: a-interesting-story
date: 2019-12-11 16:08
status: publish
author: AlanDecode
categories:
- Daily
tags:
- Travel
- Family
---
```
`frontmatter` 开始和结束于 `---`, 它将信息储存为 `key: value`。 下面列出了所有可用的选项:
| Key | Required | Default Value | Possible Value | Explanation |
| :----------: | -------- | ------------- | ---------------------- | ------------------------------------------------------------ |
| `layout` | false | post | post, page | Type of this article. |
| `title` | true | - | - | The of this article |
| `slug` | true | `title` | - | Maverick uses this value to generate URL of this article. For example: `https://me.com/archives/a-interesting-story`. |
| `date` | true | - | - | Publish date of this article in `yyyy-mm-dd hh:ss` format. |
| `status` | false | publish | publish, hidden, draft | Status of this article. |
| `author` | false | - | - | Author of this article. |
| `excerpt` | false | - | - | Will be used as excerpt of this article in home page and HTML `head` tag. If not set, Maverick will try to find `` and use content before as excerpt. If still not found, the first paragraph will be used. |
| `showfull` | false | false | true, false | If set to `true`, full content will show in home page. |
| `comment` | false | false | true, false | Turn on comment for this article. See how to enable comment in [Comment][4] section. |
| `tags` | false | - | - | Tags of this article. If there are multiple tags, write them as above. Don't forget spaces before and after `-`. |
| `categories` | false | - | - | Categories of this article. If there are multiple categories, write them as above. Don't forget spaces before and after `-` |
我建议您保留一份 Maverick 随附的示例文章样本,以作为这些选项的参考。
## Configurations | 构建
尽管 Maverick 比许多其他生成器要简单得多,但是它确实有一些需要注意的配置,可以在config.py中进行修改。 下面列出了所有这些选项。
### Options for Maverick | Maverick 的选项
| Option | Default Value | Explanation |
| ------------------------- | ----------------------------------------------- | ------------------------------------------------------------ |
| `site_prefix` | `"/"` | 网站目录。This value will be used to generate permalinks of your posts. Possible values are like `https://myblog.com/` or `https://me.com/blog/` or just `/blog/`. If you want to put your site under sub directory, this option can be useful. Don't forget `/` at the end. |
| `source_dir` | `"./test_src/"` | 源文件夹。A directory in which Maverick will try to find your articles. This can be any location on your machine, so feel free to store your articles in Dropbox, iCloud Drive or anywhere else to get them synced across multiple devices. |
| `build_dir` | `"./test_dist/"` | 静态文件生成文件夹。Where Maverick should place all generated HTML files. This can be any location on your machine, just make sure you have write permission on it. |
| `template` | `"Galileo"` | 主题文件夹。Specify the template to render your site. Please refer to [Themes][5] for more details. |
| `index_page_size` | `10` | 主页文章数量。The number of posts to show per page, change it to any number you like. |
| `archives_page_size` | `30` | 归档页文章数量。The number of posts to show per page in archive list, category list and tag list. |
| `fetch_remote_imgs` | `False` | 是否拉去远端图片。Specify how Maverick will take care of your images. Please refer to [Images and Static Assets][6] for more details. |
| `locale` | `Asia/Shanghai` | 本地时区。Specify where you are. Valid options are listed [here][7]. |
| `enable_jsdelivr` | { "enabled": False, "repo": "" } | 是不是启用 jsdelivr 。If you host your site on GitHub Pages, this option can enable [jsDelivr][8] as CDN service for all your static files, including JS files, CSS files and images. See `config.py` and preview site for an example. Basically, set `"enabled"` to `True` and set `"repo"` to `/@`. |
| `category_by_folder` | `False` | 分类方式。Category contents by folder structure rather than front-matter. |
### Options for Your Site | 你网站的选项
| Option | Default Value | Explanation |
| ----------------- | ----------------------------------------- | ------------------------------------------------------------ |
| `site_name` | `"Hellow Maverick!"` | 网站标题。Website name. Change it to something really cool! |
| `site_logo` | - | 网站 logo。Website logo. Better be a square image. |
| `site_build_date` | `"2019-12-06T12:00+08:00"` | 网站创建时间。When you build this site. |
| `author` | - | 作者名称。Author's name. |
| `email` | - | 作者邮件。Author's email. |
| `author_homepage` | `"/"` | 作者主页。Author's homepage. |
| `description` | `"A marvelous site powered by Maverick!"` | 网站描述。Description of your site. |
| `keywords` | - | 网站关键字。Four or five keywords about your site. |
| `external_links` | - | 友情链接。Will be used in `Links` section on home page. |
| `nav` | - | Will be used to generate navigations behind site title. |
| `social_links` | - | 社交链接。Will be used to generate social links behind site title. |
| `valine` | - | 评论配置。Maverick now supports Valine as its comment system. Please refer to [Comments][9] for more information. |
| `head_addon` | - | 添加到 `` 的内容。Content here will be added to `` tag of generated HTMLs, you can put some `meta` tag here, or use `` and `