Skip to content

Commit

Permalink
添加热门标签功能,分页功能完整移植
Browse files Browse the repository at this point in the history
  • Loading branch information
ctaoist committed Dec 13, 2021
1 parent 6ea88fa commit a11cb06
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 62 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@
- 可选的 Leancloud 文章阅读量统计、Leanote 自带的阅读量统计
- Mermaid、ChartJs 图表
- Google 分析
- 博文置顶

## 安装

这个分支对应官方发布的Leanote,当前的最新版为2.6.1,其分类页面的逻辑和 Hexo、Jekyll、Hugo 等静态博客都不一样,所以有关分类的功能不可用,其他功能正常。如果想体验完整的功能,请切换到 master 分支。
这个分支对应我修改过的 [Leanote](https://github.com/ctaoist/leanote)。如果只想使用官方发布的Leanote服务端,请切换到 `leanote_2.6` 分支。

本分支的安装流程如下:

1. 参考 [Leanote Wiki](https://github.com/leanote/leanote/wiki/Leanote-%E4%BA%8C%E8%BF%9B%E5%88%B6%E7%89%88%E8%AF%A6%E7%BB%86%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B----Mac-and-Linux) 安装 Leanote 服务端
2.[Releases页面](https://github.com/ctaoist/leanote-theme-chirpy/releases) 下载 **1.0.x** 版本的压缩包,或者下载仓库 `leanote_2.6` 分支的压缩包,在 Leanote 主题配置页面导入即可。
1. 参考 [Leanote Wiki](https://github.com/leanote/leanote/wiki/Leanote-%E4%BA%8C%E8%BF%9B%E5%88%B6%E7%89%88%E8%AF%A6%E7%BB%86%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B----Mac-and-Linux) 安装我修改过的 [Leanote 服务端](https://github.com/ctaoist/leanote/releases)
2.[Releases页面](https://github.com/ctaoist/leanote-theme-chirpy/releases) 下载 **1.1.x** 版本的压缩包,或者下载仓库 `master` 分支的压缩包,在 Leanote 主题配置页面导入即可。

## 使用

Expand Down Expand Up @@ -95,8 +96,8 @@ Gitalk 需要手动初始化所有文章的评论:用自己的 Github 账号
1. [x] MathJax 升级到3.0后,不使用原来的代码,公式中的换行(双斜杠)会被转义成单斜杠,暂代方案是使用(`\\\`)或者 `\newlineh` 或者 [`\displaylines`](https://github.com/mathjax/MathJax/issues/2312)。目前是参考了 [Hexo下mathjax的转义问题](https://segmentfault.com/a/1190000007261752)[使Marked.js与MathJax共存](https://blog.csdn.net/emptyset110/article/details/50123231), 取消了对 `\\``\{}` 的转义,公式能够正常换行,但有没有别的 Bug 还有待观察
1. [x] 代码块下部离文字太近
1. [x] post 的阅读次数没有增加:可选使用 Leanote 自带的阅读计数或者用 LeanCloud 的阅读计数
1. [] Leanote 的分类页面的逻辑和 Jekyll、Hexo 等的不一样,Leanote 不渲染相应的页面,所以分类页面虽然完成了移植,但功能不可用
1. [] 将博客设置里的排序方式改成按照创建时间排序后,影响的只有主页的排序,归档页面仍然是按照 PublicTime 排序的。
1. [x] Leanote 的分类页面的逻辑和 Jekyll、Hexo 等的不一样,Leanote 服务端已修改相应逻辑
1. [x] 将博客设置里的排序方式改成按照创建时间排序后,影响的只有主页的排序,归档页面仍然是按照 PublicTime 排序的。已修复

## 反馈

Expand Down
68 changes: 49 additions & 19 deletions cates.html
Original file line number Diff line number Diff line change
@@ -1,38 +1,68 @@
{{template "header.html" .}}

<div id="main-wrapper">
<div id="main">
<div class="row">
<div class="col-12 col-lg-11 col-xl-8">
<div id="page" class="post pb-5 pl-1 pr-1 pl-sm-2 pr-sm-2 pl-md-4 pr-md-4 mb-md-4">
<h1 class="dynamic-title">Tags</h1>
<div class="post-content">
<!-- leanote 不渲染这个页面 -->
{{range $.cates}}
<div id="main">
<div class="row">
<div class="col-12 col-lg-11 col-xl-8">
<div id="page" class="post pb-5 pl-1 pr-1 pl-sm-2 pr-sm-2 pl-md-4 pr-md-4 mb-md-4">
<h1 class="dynamic-title">Categories</h1>
<div class="post-content">
{{range $group_index, $cate := $.cates}}
<div class="card categories">
<!-- top-category -->
<div id="h_0" class="card-header d-flex justify-content-between hide-border-bottom">
<div id="h_{{ $group_index }}" class="card-header d-flex justify-content-between hide-border-bottom">
<span>
<i class="far fa-folder fa-fw"></i>
<a href="{{$.cateUrl}}/{{.UrlTitle}}" class="ml-1 mr-2">{{.Title}}</a>
<a href="{{$.cateUrl}}/{{$cate.UrlTitle}}" class="ml-1 mr-2">{{$cate.Title}}</a>
<span class="text-muted small font-weight-light">
{{if gt $cate.SubCateCount 0}} {{$cate.SubCateCount}} categories, {{end}} {{$cate.CateCount}} posts
</span>
</span>

<!-- arrow -->
{{ if gt $cate.SubCateCount 0 }}
<a href="#l_{{ $group_index }}" data-toggle="collapse"
aria-expanded="true" aria-label="h_{{ $group_index }}-trigger"
class="category-trigger hide-border-bottom">
<i class="fas fa-fw fa-angle-down"></i>
</a>
{{ else }}
<span data-toggle="collapse" class="category-trigger hide-border-bottom disabled">
<i class="fas fa-fw fa-angle-right"></i>
</span>
{{ end }}
</div> <!-- .card-header -->

<!-- Sub-categories -->
{{ if gt $cate.SubCateCount 0 }}
<div id="l_{{ $group_index }}" class="collapse show" aria-expanded="true">
<ul class="list-group">
{{ range $cate.SubCates }}
<li class="list-group-item">
<i class="far fa-folder fa-fw"></i>
<a href="{{$.cateUrl}}/{{.UrlTitle}}" class="ml-1 mr-2">{{ .Title }}</a>
<span class="text-muted small font-weight-light">{{ .CateCount }} posts</span>
</li>
{{ end }}
</ul>
</div>
{{ end }}

</div> <!-- .card -->
{{end}}

</div> <!-- .post-content -->
</div> <!-- #page -->
</div>
</div> <!-- .post-content -->
</div> <!-- #page -->
</div>

<div id="panel-wrapper" class="col-xl-3 pl-2 text-muted topbar-down">
{{template "post-update-list-trending-tags.html" .}}
</div> <!-- panel-wrapper -->
<div id="panel-wrapper" class="col-xl-3 pl-2 text-muted topbar-down">
{{template "post-update-list-trending-tags.html" .}}
</div> <!-- panel-wrapper -->

</div> <!-- .row -->
</div> <!-- .row -->

{{template "footer.html" .}}
</div> <!-- #main -->
{{template "footer.html" .}}
</div> <!-- #main -->
</div> <!-- #main-wrapper -->
{{template "back-to-top.html" .}}
</body>
Expand Down
45 changes: 25 additions & 20 deletions header.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@
<link rel="Shortcut icon" href="{{$.themeBaseUrl}}/images/{{$.themeInfo.Icon}}">

<title>
{{if $.curIsIndex}}
{{$.blogInfo.Title}}
{{else if $.curIsCate}}
Category-{{$.curCateTitle}}
{{else if $.curIsSearch}}
Search-{{$.keywords}}
{{else if $.curIsTags}}
Tags
{{else if $.curIsTagPosts}}
Tag-{{$.curTag}}
{{else if $.curIsPost}}
{{$.post.Title}}
{{else if $.curIsSingle}}
{{$.single.Title}}
{{else if $.curIsArchive}}
Archives
{{end}}

{{if $.curIsIndex}}
{{$.blogInfo.Title}}
{{else if $.curIsCate}}
Category-{{$.curCateTitle}}
{{else if $.curIsSearch}}
Search-{{$.keywords}}
{{else if $.curIsTags}}
Tags
{{else if $.curIsCates}}
Categories
{{else if $.curIsTagPosts}}
Tag-{{$.curTag}}
{{else if $.curIsPost}}
{{$.post.Title}}
{{else if $.curIsSingle}}
{{$.single.Title}}
{{else if $.curIsArchive}}
Archives
{{end}}
</title>

<!-- jsDelivr CDN -->
<link rel="preconnect" href="https://cdn.jsdelivr.net">
<link rel="dns-prefetch" href="https://cdn.jsdelivr.net">
Expand Down Expand Up @@ -101,7 +101,7 @@
</li>
<!-- categories -->
<li class="nav-item{{if $.curIsCate}} active{{end}}">
<a href="/?cates=undefined" class="nav-link">
<a href="{{$.catesUrl}}" class="nav-link">
<i class="fa-fw fas fa-stream ml-xl-3 mr-xl-3 unloaded"></i>
<span>Categories</span>
</a>
Expand Down Expand Up @@ -158,6 +158,11 @@
<span>{{$.post.Title}}</span>
{{else if $.curIsTags}}
<span>Tags</span>
{{else if $.curIsCates}}
<span>Categories</span>
{{else if $.curIsCate}}
<span><a href="{{$.catesUrl}}">Categories</a></span>
<span>{{$.curCateTitle}}</span>
{{else if $.curIsTagPosts}}
<span><a href="{{$.tagsUrl}}">Tags</a></span>
<span>{{$.curTag}}</span>
Expand Down
15 changes: 8 additions & 7 deletions post.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ <h1 id="post-title" data-toc-skip>{{if .post.Title}} {{.post.Title}} {{else}} Un

<div class="post-tail-wrapper text-muted">
<!-- categories -->
<!-- <div class="post-meta mb-3">
<i class="far fa-folder-open fa-fw mr-1"></i>
{% for category in page.categories %}
<a href='/'></a>
{%- unless forloop.last -%}, {%- endunless -%}
{% endfor %}
</div> -->
{{ if .post.Cates}}
<div class="post-meta mb-3">
<i class="far fa-folder-open fa-fw mr-1"></i>
{{ range .post.Cates }}
<a href="{{$.cateUrl}}/{{.UrlTitle}}">{{.Title}}</a>
{{ end }}
</div>
{{ end }}

<!-- tags -->
<div class="post-tags">
Expand Down
7 changes: 7 additions & 0 deletions post_abstract.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ <h1><a href="{{$.postUrl}}/{{.UrlTitle}}" title="{{.Title}}">
{{end}}
{{end}}
</div>
<!-- pin -->
{{ if .IsTop }}
<div class="pin">
<i class="fas fa-thumbtack fa-fw"></i>
<span>Pinned</span>
</div>
{{ end }}
</div> <!-- .post-meta -->
</div> <!-- .post-review -->
{{else}}
Expand Down
16 changes: 5 additions & 11 deletions theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@
"clientSecret": "",
"repo": "",
"owner": "",
"admin": [
""
]
"admin": [ "" ]
},
"Disqus": {
"DisqusId": ""
Expand All @@ -60,13 +58,9 @@
{"Title": "twitter", "Url": "https://twitter.com/ctaoist"}
],
"FriendLinks": [
{"Title": "Leanote Home", "Url": "http://leanote.com"
},
{"Title": "Leanote Comunity", "Url": "https://groups.google.com/forum/?fromgroups#!forum/leanote"
},
{"Title": "lea++", "Url": "http://lea.leanote.com"
},
{"Title": "Leanote Github", "Url": "https://github.com/leanote/leanote"
}
{"Title": "Leanote Home", "Url": "http://leanote.com"},
{"Title": "Leanote Comunity", "Url": "https://groups.google.com/forum/?fromgroups#!forum/leanote"},
{"Title": "lea++", "Url": "http://lea.leanote.com"},
{"Title": "Leanote Github", "Url": "https://github.com/leanote/leanote"}
]
}

0 comments on commit a11cb06

Please sign in to comment.