Skip to content

Commit

Permalink
Merge pull request #137 from w568w/master
Browse files Browse the repository at this point in the history
Fix several issues
  • Loading branch information
imeoer authored Jan 31, 2023
2 parents c422f60 + f8eb47d commit eaf0299
Show file tree
Hide file tree
Showing 12 changed files with 174 additions and 67 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

InkPaper is a static blog generator developed in Golang. No dependencies, cross platform, easy to use, fast building times and an elegant theme.

[![release](https://img.shields.io/badge/release-v2018--07--27-blue.svg)](http://www.chole.io/)
[![release](https://img.shields.io/badge/release-v2018--07--27-blue.svg)](https://github.com/InkProject/ink)
[![apm](https://img.shields.io/badge/license-CC%20BY--NC%204.0-blue.svg)](https://creativecommons.org/licenses/by-nc/4.0/)


Expand Down Expand Up @@ -112,6 +112,8 @@ Docker Build (Example)

- Dark (Official Theme): [https://github.com/InkProject/ink-theme-dark](https://github.com/InkProject/ink-theme-dark)
- Simple: [https://github.com/myiq/ink-simple](https://github.com/myiq/ink-simple)
- Story: [https://github.com/akkuman/ink-theme-story](https://github.com/akkuman/ink-theme-story)
- Material2: [https://github.com/w568w/InkMaterialTheme](https://github.com/w568w/InkMaterialTheme)

## Related Tutorials

Expand Down
6 changes: 3 additions & 3 deletions parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type ArticleConfig struct {
Hide bool
Image string
Subtitle string
Config interface{}
Config map[string]interface{}
}

type Article struct {
Expand Down Expand Up @@ -130,7 +130,7 @@ func renderHookLazyLoadImage(w io.Writer, node ast.Node, entering bool) (ast.Wal
}

func ParseMarkdown(markdown string) template.HTML {
extensions := parser.CommonExtensions
extensions := parser.CommonExtensions | parser.Footnotes
parser := parser.NewWithExtensions(extensions)

htmlFlags := html.CommonFlags
Expand Down Expand Up @@ -241,7 +241,7 @@ func ParseArticle(markdownPath string) *Article {
return nil
}
if config.Config == nil {
config.Config = ""
config.Config = make(map[string]interface{})
}
var article Article
// Parse markdown content
Expand Down
4 changes: 3 additions & 1 deletion template/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ site:
limit: 10
theme: theme
lang: zh-cn
url: "http://www.chole.io/blog"
url: "https://example.io/"
comment: username
logo: "-/images/avatar.png"
config:
CustomVar: "config 下是纸小墨的自定义变量,定义时建议使用正确大小写"
# link: "{category}/{year}/{month}/{day}/{title}.html"
# link: "{year}{month}{day}{hour}{minute}{second}.html"
# root: "/blog"
Expand Down
2 changes: 1 addition & 1 deletion template/source/about.me.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ author: me

构建只为纯粹书写的博客。

[http://www.chole.io/](http://www.chole.io/)
[https://github.com/InkProject/ink](https://github.com/InkProject/ink)
28 changes: 26 additions & 2 deletions template/source/ink-blog-tool-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ InkPaper is a static blog generator developed in Golang. No dependencies, cross
![InkPaper - An Elegant Static Blog Generator](-/images/example-en.png)

### Quick Start
- Download & Extract [Ink](http://www.chole.io/) and run `ink preview`
- Download & Extract [Ink](https://github.com/InkProject/ink) and run `ink preview`

> Tip:Linux/macOS, use `./ink preview`
Expand Down Expand Up @@ -94,6 +94,30 @@ page `page.html` (article list) and `article.html` (article), use variable with

Created any `.html` file will be copied to `source` directory, could use all variables on `site` field in `config.yml`.

#### Define Custom Variables
InkPaper supports defining custom variables in pages, which must be placed under `site.config` in `config.yaml`, such as:

``` yaml
site:
config:
MyVar: "Hello World"
```

The variable can be referenced in the page by `{{.Site.Config.MyVar}}`.

> **Note**
>
> Although the field names in other parts of `config.yaml` are all lowercase, the name of the custom variable must be used correctly, such as:
>
> ```yaml
site:
config:
MYVAR_aaa: "Hello World"
```
> then the variable must be referenced in the page by `{{.Site.Config.MYVAR_aaa}}`.


### Blog Migrate (Beta)

Supports simple Jeklly/Hexo post convertions. Usage:
Expand Down Expand Up @@ -146,7 +170,7 @@ Docker Build (Example)

## These blogs are driven by InkPaper

- [http://www.chole.io/blog/](http://www.chole.io/blog/)
- [https://imeoer.github.io/blog/](https://imeoer.github.io/blog/)
- [http://blog.hyper.sh/](http://blog.hyper.sh/)
- [http://wangxu.me/](http://wangxu.me/)
- [http://whzecomjm.com/](http://whzecomjm.com/)
Expand Down
27 changes: 25 additions & 2 deletions template/source/ink-blog-tool.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ preview: 纸小墨(InkPaper)是一个GO语言编写的开源静态博客构

### 开始上手

- 下载并解压 [Ink](http://www.chole.io/),运行命令 `ink preview`
- 下载并解压 [Ink](https://imeoer.github.io/),运行命令 `ink preview`

> 注意:Linux/macOS下,使用 `./ink preview`
Expand Down Expand Up @@ -106,6 +106,29 @@ Markdown格式的正文

在`source`目录下创建的任意`.html`文件将被复制,这些文件中可引用`config.yml`中site字段下的所有变量。

#### 定义自定义变量
纸小墨支持在页面中定义自定义变量,必须放置于 `config.yaml` 的 `site.config` 之下,如:

``` yaml
site:
config:
MyVar: "Hello World"
```

在页面中可通过 `{{.Site.Config.MyVar}}` 来引用该变量。

> **注意**
>
> 虽然 `config.yaml` 的其他部分字段名均为小写,但自定义变量的名称必须使用正确的大小写,如:

> ```yaml
site:
config:
MYVAR_aaa: "Hello World"
```
> 则在页面中必须使用 `{{.Site.Config.MYVAR_aaa}}` 来引用该变量。

### 博客迁移(Beta)

纸小墨提供简单的Jeklly/Hexo博客文章格式转换,使用命令:
Expand Down Expand Up @@ -155,7 +178,7 @@ Docker构建(示例)

## 正在使用

- [http://www.chole.io/blog/](http://www.chole.io/blog/)
- [https://imeoer.github.io/blog/](https://imeoer.github.io/blog/)
- [http://blog.hyper.sh/](http://blog.hyper.sh/)
- [http://wangxu.me/](http://wangxu.me/)
- [http://whzecomjm.com/](http://whzecomjm.com/)
Expand Down
2 changes: 1 addition & 1 deletion template/theme/_footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
document.write(new Date().getFullYear());
</script>
</span>
<span class="publish">Powered by <a href="http://www.chole.io/" target="_blank">Ink</a></span>
<span class="publish">Powered by <a href="https://github.com/InkProject/ink" target="_blank">Ink</a></span>
</footer>
2 changes: 1 addition & 1 deletion template/theme/bundle/index.css

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions template/theme/bundle/index.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion template/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"devDependencies": {
"autoprefixer": "^10.4.2",
"css-loader": "^6.6.0",
"css-minimizer-webpack-plugin": "^4.2.2",
"uglifyjs-webpack-plugin": "^2.2.0",
"file-loader": "^6.2.0",
"mini-css-extract-plugin": "^2.6.0",
"postcss": "^8.4.7",
Expand All @@ -25,4 +27,4 @@
"dependencies": {
"jquery": "^3.6.3"
}
}
}
Loading

0 comments on commit eaf0299

Please sign in to comment.