optimization toc,fix bugs, close #13,close #45,close #46,close #68

This commit is contained in:
飞雪无情
2019-12-20 18:02:14 +08:00
parent dace469f91
commit 5b068f5fcc
18 changed files with 354 additions and 79 deletions
+7 -30
View File
@@ -41,7 +41,7 @@ Maupassant theme, ported to Hugo.
```bash
cd <YOUR Bolg Root Dir>
git clone https://github.com/rujews/maupassant-hugo themes/maupassant
git clone https://github.com/flysnow-org/maupassant-hugo themes/maupassant
```
## 配置
@@ -52,40 +52,17 @@ git clone https://github.com/rujews/maupassant-hugo themes/maupassant
theme = "maupassant"
```
#### 基本配置
#### 快速开始
```toml
baseURL = "http://www.flysnow.org"
languageCode = "zh-CN"
title = "飞雪无情的博客"
theme = "maupassant"
在主题的 [exampleSite](exampleSite/) 示例目录下有`config.toml `文件,把`config.toml `文件复制到你的站点目录下,然后根据自己的需求修改即可
## 保持分类的原始名字(false会做转小写处理)
preserveTaxonomyNames = true
## 是否禁止URL Path转小写
disablePathToLower = true
**PS: 一定要使用`post`目录,而不是`posts`,一定要记住,所以如果你使用`hugo`命令,你应该`hugo new post/filename.md`这样创建**
hasCJKLanguage = true
summaryLength = 140
**PS: 一定要使用`post`目录,而不是`posts`,一定要记住,所以如果你使用`hugo`命令,你应该`hugo new post/filename.md`这样创建**
[author]
name = "飞雪无情"
**PS: 一定要使用`post`目录,而不是`posts`,一定要记住,所以如果你使用`hugo`命令,你应该`hugo new post/filename.md`这样创建**
[params]
author = "飞雪无情"
subtitle = "专注于Android、Java、Go语言(golang)、移动互联网、项目管理、软件架构"
keywords = "golang,go语言,go语言笔记,飞雪无情,java,android,博客,项目管理,python,软件架构,公众号,小程序"
description = "专注于IT互联网,包括但不限于Go语言(golang)、Java、Android、Python、项目管理、抖音分析、软件架构等"
busuanzi = true
localSearch = true
[markup]
[markup.highlight]
lineNos = true
style = "github"
```
基本配置大家都比较熟悉,这是我的博客的配置,仅供参考。
#### 代码高亮
@@ -431,7 +408,7 @@ disablePathToLower = true
+ Wordpresshttps://github.com/iMuFeng/maupassant/
+ Ghost: https://github.com/LjxPrime/maupassant/
+ Hexo: https://github.com/tufu9441/maupassant-hexo
+ Hugo: https://github.com/rujews/maupassant-hugo
+ Hugo: https://github.com/flysnow-org/maupassant-hugo
```
+4 -18
View File
@@ -16,7 +16,7 @@ A simple Hugo template with great performance on different devices, ported from
```bash
cd <YOUR Bolg Root Dir>
git clone https://github.com/rujews/maupassant-hugo themes/maupassant
git clone https://github.com/flysnow-org/maupassant-hugo themes/maupassant
```
## Configuration
@@ -27,23 +27,9 @@ git clone https://github.com/rujews/maupassant-hugo themes/maupassant
theme = "maupassant"
```
#### Basic Configuration
#### Quick Start
```toml
baseURL = "http://www.flysnow.org"
languageCode = "zh-CN"
title = "飞雪无情的博客"
theme = "maupassant"
[author]
name = "飞雪无情"
[params]
author = "飞雪无情"
subtitle = "专注于Android、Java、Go语言(golang)、移动互联网、项目管理、软件架构"
keywords = "golang,go语言,go语言笔记,飞雪无情,java,android,博客,项目管理,python,软件架构,公众号,小程序"
description = "专注于IT互联网,包括但不限于Go语言(golang)、Java、Android、Python、项目管理、抖音分析、软件架构等"
```
See [exampleSite](exampleSite/) folder, copy the`config.toml` in the root folder of your Hugo site and change it to your needs.
#### Menus
@@ -272,4 +258,4 @@ Looking forward to your pull request.
+ Wordpresshttps://github.com/iMuFeng/maupassant/
+ Ghost: https://github.com/LjxPrime/maupassant/
+ Hexo: https://github.com/tufu9441/maupassant-hexo
+ Hugo: https://github.com/rujews/maupassant-hugo
+ Hugo: https://github.com/flysnow-org/maupassant-hugo
+6
View File
@@ -1,2 +1,8 @@
+++
title='{{ replace .Name "-" " " | title }}'
tags=[]
categories=[]
date="{{ .Date }}"
toc=true
draft=true
+++
+102
View File
@@ -0,0 +1,102 @@
baseURL = "https://www.flysnow.org"
languageCode = "zh-CN"
title = "飞雪无情的博客"
theme = "maupassant"
googleAnalytics = "" # UA-XXXXXXXX-X
## 保持分类的原始名字(false会做转小写处理)
preserveTaxonomyNames = true
## 是否禁止URL Path转小写
disablePathToLower = true
hasCJKLanguage = true
summaryLength = 140
disqusShortname = "yourdiscussshortname" ## 是否开启disqus评论,不要和utteranc同时开启
[author]
name = "飞雪无情"
[params]
author = "飞雪无情"
subtitle = "专注于Android、Java、Go语言(golang)、移动互联网、项目管理、软件架构"
keywords = "golang,go语言,go语言笔记,飞雪无情,java,android,博客,项目管理,python,软件架构,公众号,小程序"
description = "专注于IT互联网,包括但不限于Go语言(golang)、Java、Android、Python、项目管理、抖音分析、软件架构等"
busuanzi = true #启用不算子网页统计
googleAd = "ca-pub-4031353640611810" #ca-pub-xxxxxxxxxxxxxx
localSearch = true # 启用本地搜索
# 这里我存放在了主题的static文件夹里,根目录的似乎也可以
customCSS = ['douban.css', 'other.css']
# if ['custom.css'], load '/static/css/custom.css' file
customJS = ['douban.js']
# if ['custom.js'], load '/static/js/custom.js' file
# 全局开关,你也可以在每一篇内容的 front matter 中针对单篇内容关闭或开启某些功能
toc = true # 是否开启目录
## 友情链接,可以多个
[[params.links]]
title = "飞雪无情的博客"
name = "飞雪无情的博客"
url = "https://www.flysnow.org/"
[[params.links]]
title = "Android Gradle权威指南"
name = "Android Gradle权威指南"
url = "http://yuedu.baidu.com/ebook/14a722970740be1e640e9a3e"
## 侧边栏广告位
[[params.ads]]
title = "【2019双12】ALL IN CLoud 低至1折"
url = "https://www.aliyun.com/minisite/goods?userCode=jdg9oj97&share_source=copy_link"
img = "https://img.alicdn.com/tfs/TB1_rYHo7P2gK0jSZPxXXacQpXa-690-388.jpg"
[[params.ads]]
title = "助力产业智慧升级,云服务器首年88元起,更有千元代金券礼包免费领!"
url = "https://cloud.tencent.com/act/cps/redirect?redirect=1048&cps_key=14ff722692ac784fa8c3301c8c28d924&from=console"
img = "https://upload-dianshi-1255598498.file.myqcloud.com/345-7c71532bd4935fbdd9a67c1a71e577b1767b805c.200%E7%89%88%E6%9C%ACB.jpg"
[[params.ads]]
title = "【渠道专享低折扣】11月特惠 限时2折"
url = "https://www.aliyun.com/acts/limit-buy?userCode=jdg9oj97"
img = "https://img.alicdn.com/tfs/TB1hblJl7Y2gK0jSZFgXXc5OFXa-750-400.jpg"
## 配置 utteranc评论,教程参考 https://utteranc.es/
[params.utteranc]
enable = true
repo = "flysnow-org/comment"
issueTerm = "pathname"
theme = "github-light"
## 开启版权声明,协议名字和链接都可以换
[params.cc]
name = "知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议"
link = "https://creativecommons.org/licenses/by-nc-nd/4.0/"
## 配置代码高亮
[markup]
[markup.highlight]
lineNos = true
style = "github"
## 配置网站菜单
[menu]
[[menu.main]]
identifier = "tools"
name = "工具"
url = "/tools/"
weight = 2
[[menu.main]]
identifier = "archives"
name = "归档"
url = "/archives/"
weight = 3
[[menu.main]]
identifier = "about"
name = "关于"
url = "/about/"
weight = 4
+15
View File
@@ -0,0 +1,15 @@
---
title: "关于我"
date: 2015-03-10 00:13:27
description: 《Go 实战笔记》系列作者,《Golang Gin 实战》系列作者,《Android Gradle权威指南》作者,现负责技术管理
---
《Go 实战笔记》系列作者,《Golang Gin 实战》系列作者,《Android Gradle权威指南》作者,现负责技术管理。
[Android Gradle权威指南](http://yuedu.baidu.com/ebook/14a722970740be1e640e9a3e)
公众号,扫码关注
![扫码关注](qrcode_for_weixin.jpg)
Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

+6
View File
@@ -0,0 +1,6 @@
---
title: "归档"
description: Android资深工程师 Go和Java打杂师,《Android Gradle权威指南》作者,Android官方技术文档译者
type: archives
---
@@ -0,0 +1,27 @@
+++
title="Golang Gin 实战(三)| 路由参数"
tags=["golang"]
categories=["Golang"]
date="2019-12-13T21:00:00+08:00"
toc=true
+++
## 标题
段落内容
## 标题
段落内容
## 标题
段落内容
## 标题
段落内容
## 标题
段落内容
@@ -0,0 +1,26 @@
+++
title="Golang Gin 实战(三)| 路由参数"
tags=["golang"]
categories=["Golang"]
date="2019-12-13T21:00:00+08:00"
+++
## 标题
段落内容
## 标题
段落内容
## 标题
段落内容
## 标题
段落内容
## 标题
段落内容
@@ -0,0 +1,28 @@
+++
title="Golang Gin 实战(五)| 接收数组和 Map"
tags=["golang"]
categories=["Golang"]
date="2019-12-18T21:55:00+08:00"
url="/2019/12/18/golang-gin-query-parameters-array-map.html"
toc=true
+++
## 标题
段落内容
## 标题
段落内容
## 标题
段落内容
## 标题
段落内容
## 标题
段落内容
+6
View File
@@ -0,0 +1,6 @@
---
title: "搜索"
description: "搜索页面"
type: "search"
---
+32
View File
@@ -0,0 +1,32 @@
{{ define "content"}}
{{- $paginator := .Paginate .Data.Pages.ByDate.Reverse 10 }}
<div class="res-cons">
{{ range $index,$data := $paginator.Pages }}
{{ if not .Params.hidden }}
<article class="post">
<header>
<h1 class="post-title">
<a href="{{ .Permalink }}" title="{{ .Title }}">{{ .Title }}</a>
</h1>
</header>
<date class="post-meta meta-date">
{{ .Date.Year }}年{{ printf "%d" .Date.Month }}月{{ .Date.Day }}日
</date>
{{ with .Params.Categories }}
<div class="post-meta">
<span>|</span>
{{ range . }}
<span class="meta-category"><a href='{{ "/categories/" | absLangURL }}{{ . | urlize }}'>{{ . }}</a></span>
{{ end }}
</div>
{{ end }}
<div class="post-content">
{{ .Summary }}……
</div>
<p class="readmore"><a href="{{ .Permalink }}">阅读全文</a></p>
</article>
{{ end }}
{{ end }}
{{ partial "paginator" . }}
</div>
{{ end }}
+1
View File
@@ -1,5 +1,6 @@
{{ define "content"}}
<div class="res-cons">
{{ partial "toc" . }}
<article class="post">
<header>
<h1 class="post-title">{{ .Title }}</h1>
+2 -3
View File
@@ -1,7 +1,7 @@
{{ define "content"}}
<div class="res-cons">
{{ range $index,$data := .Paginator.Pages }}
{{ if not .Params.hidden }}
{{- $paginator := .Paginate (where .Site.RegularPages "Type" "in" (slice "post" "posts")) }}
{{ range $index,$data := $paginator.Pages }}
<article class="post">
<header>
<h1 class="post-title">
@@ -25,7 +25,6 @@
<p class="readmore"><a href="{{ .Permalink }}">阅读全文</a></p>
</article>
{{ end }}
{{ end }}
{{ partial "paginator" . }}
</div>
{{ end }}
+3 -3
View File
@@ -2,7 +2,7 @@
<div class="container">
&copy; {{ now.Format "2006" }} <a href="{{ .Site.BaseURL | absURL }}">{{ .Site.Title }} By {{ .Site.Author.name }}</a>.
Powered by <a rel="nofollow noreferer noopener" href="https://gohugo.io" target="_blank">Hugo</a>.
<a href="https://www.flysnow.org/" target="_blank">Theme</a> based on <a href="https://github.com/rujews/maupassant-hugo" target="_blank">maupassant</a>.
<a href="https://www.flysnow.org/" target="_blank">Theme</a> based on <a href="https://github.com/flysnow-org/maupassant-hugo" target="_blank">maupassant</a>.
{{ if .Site.Params.showHostPage }}
Hosted by <a rel="nofollow noreferer noopener" href="https://pages.coding.me" target="_blank">Coding Pages</a>.
{{ end }}
@@ -114,7 +114,7 @@
{{ end }}
<a id="rocket" href="#top"></a>
<script type="text/javascript" src="{{ "js/totop.js?v=0.0.0" | relURL }}" async=""></script>
<script type="text/javascript" src='{{ "js/totop.js?v=0.0.0" | relURL }}' async=""></script>
{{ template "_internal/google_analytics_async.html" . }}
{{ if .Site.Params.busuanzi }}
@@ -123,5 +123,5 @@
<!-- custom js -->
{{ range .Site.Params.customJS }}
<script src="{{ "/js/" | relURL }}{{ . }}"></script>
<script src='{{ "/js/" | relURL }}{{ . }}'></script>
{{ end }}
+89
View File
@@ -0,0 +1,89 @@
{{ if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) -}}
<style type="text/css">
.post-toc {
position: fixed;
width: 200px;
margin-left: -220px;
padding: 5px 10px;
font-family: Athelas, STHeiti, Microsoft Yahei, serif;
font-size: 12px;
border: 1px solid rgba(0, 0, 0, .07);
border-radius: 5px;
background-color: rgba(255, 255, 255, 0.98);
background-clip: padding-box;
-webkit-box-shadow: 1px 1px 2px rgba(0, 0, 0, .125);
box-shadow: 1px 1px 2px rgba(0, 0, 0, .125);
word-wrap: break-word;
white-space: nowrap;
-webkit-box-sizing: border-box;
box-sizing: border-box;
z-index: 999;
cursor: pointer;
max-height: 70%;
overflow-y: auto;
overflow-x: hidden;
}
.post-toc .post-toc-title {
margin: 0 10px;
font-size: 20px;
font-weight: 400;
text-transform: uppercase;
}
.post-toc .post-toc-content {
font-size: 15px;
}
.post-toc .post-toc-content>nav>ul {
margin: 10px 0;
}
.post-toc .post-toc-content ul {
padding-left: 20px;
list-style: square;
margin: 0.5em;
line-height: 1.8em;
}
.post-toc .post-toc-content ul ul {
padding-left: 15px;
display: none;
}
@media print,
screen and (max-width:1057px) {
.post-toc {
display: none;
}
}
</style>
<div class="post-toc" style="position: absolute; top: 188px;">
<h2 class="post-toc-title">文章目录</h2>
<div class="post-toc-content">
{{.TableOfContents}}
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
var postToc = $(".post-toc");
if (postToc.length) {
var t = postToc.offset().top - 20,
a = {
start: {
position: "absolute",
top: t
},
process: {
position: "fixed",
top: 20
},
};
$(window).scroll(function () {
var e = $(window).scrollTop();
e < t ? postToc.css(a.start) : postToc.css(a.process)
})
}
})
</script>
{{- end }}
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 434 KiB

After

Width:  |  Height:  |  Size: 78 KiB

-25
View File
@@ -1042,28 +1042,3 @@ table tr th, table tr td {
padding: 0.5em 1em;
text-align: left;
}
/* toc*/
.toc-article {
border: 1px solid #bbb;
border-radius: 7px;
margin: 1.1em 0 0 2em;
padding: 0.7em 0.7em 0 0.7em;
max-width: 40%;
line-height: 1em;
float: right;
}
.toc-title {
font-size: 120%;
}
#TableOfContents {
}
#TableOfContents ul {
padding: 0;
margin: 0.5em;
line-height: 1.8em;
}
#TableOfContents li {
list-style-type: none;
}