Skip to content

Commit

Permalink
增加waline评论系统;支持从首页隐藏某些文章 (flysnow-org#149)
Browse files Browse the repository at this point in the history
* Update README

* 增加从首页隐藏选项

* 可根据设置隐藏文章

* 增加Waline评论系统
  • Loading branch information
Qutue authored Apr 17, 2022
1 parent 2a98cd7 commit 1d4222e
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 4 deletions.
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Maupassant theme, ported to Hugo.
15. See Also 支持
16. Disqus评论支持
18. 自定义css、js
19. utteranc评论
19. utteranc和[waline](https://waline.js.org)评论
20. 部分自定义的shortcode
21. 文章自定义摘要
22. 自定义广告支持
Expand Down Expand Up @@ -295,6 +295,18 @@ summaryLength = 140
3. `title` 按页面title标题的方式。

其他还有几个不常用,这里就不再赘述了。
#### Waline 评论系统
Waline一款从 Valine 衍生的带后端评论系统。快速、安全、免费部署、支持评论通知。详见[https://waline.js.org/](https://waline.js.org/)

```enable```值改为```true```即可启用

```serverURL```可根据官网部署教程获取
```toml
[params.waline]
enable = false
placeholder = "说点什么吧..."
serverURL = "Your waline serverURL" #换成你的serverURL
```

#### 不蒜子页面计数器支持

Expand Down Expand Up @@ -445,6 +457,24 @@ disablePathToLower = true
}
​```
```
#### 支持在首页上隐藏某篇文章

将 front matter 中的```hiddenFromHomePage```设置为```true``` 即可

*默认为```false```*

```toml
+++
title = '{{ replace .Name "-" " " | title }}'
tags = []
categories = []
date = "{{ .Date }}"
toc = true
draft = true
hiddenFromHomePage = false
+++

```

## 贡献

Expand Down
26 changes: 26 additions & 0 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,32 @@ summaryLength = 140

```toml
disqusShortname = "yourdiscussshortname"
```
#### Waline comment system
See [https://waline.js.org/](https://waline.js.org/)

```toml
[params.waline]
enable = false
placeholder = "说点什么吧..."
serverURL = "Your waline serverURL"
```

#### Hide some articles on the homepage

Change the value of ```hiddenFromHomePage``` to ```true``` to enable

```toml
+++
title = '{{ replace .Name "-" " " | title }}'
tags = []
categories = []
date = "{{ .Date }}"
toc = true
draft = true
hiddenFromHomePage = false
+++

```

#### Page View Support
Expand Down
1 change: 1 addition & 0 deletions archetypes/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ categories=[]
date="{{ .Date }}"
toc=true
draft=true
hiddenFromHomePage= false
+++
6 changes: 5 additions & 1 deletion exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ disqusShortname = "yourdiscussshortname" ## 是否开启disqus评论,不要
repo = "your github repo" ##换成自己得
issueTerm = "pathname"
theme = "github-light"

## 配置 waline 评论系统,教程参考 https://waline.js.org/
[params.waline]
enable = false
placeholder = "说点什么吧..."
serverURL = "Your waline serverURL" #换成你的serverURL
## 开启版权声明,协议名字和链接都可以换
[params.cc]
name = "知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议"
Expand Down
4 changes: 3 additions & 1 deletion layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<div class="res-cons">
{{- $paginator := .Paginate (where .Site.RegularPages "Type" "in" (slice "post" "posts")) }}
{{ range $index,$data := $paginator.Pages }}
{{if not .Params.hiddenFromHomePage }}
<article class="post">
<header>
<h1 class="post-title">
Expand All @@ -25,6 +26,7 @@ <h1 class="post-title">
<p class="readmore"><a href="{{ .Permalink }}">阅读全文</a></p>
</article>
{{ end }}
{{ end }}
{{ partial "paginator" . }}
</div>
{{ end }}
{{ end }}
14 changes: 13 additions & 1 deletion layouts/partials/comments.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,16 @@
</script>
</div>
{{ end }}
{{- end }}
<!--waline-->
{{ if .Site.Params.waline.enable }}
<div id="waline"></div>
<script src="//cdn.jsdelivr.net/npm/@waline/client"></script>
<script>
Waline({
el: '#waline',
serverURL: '{{ .Site.Params.waline.serverURL }}',
placeholder: '{{ .Site.Params.waline.placeholder }}',
});
</script>
{{ end }}
{{- end }}

0 comments on commit 1d4222e

Please sign in to comment.