Skip to content

Commit

Permalink
feat: 在页脚显示阅读量、分类、点赞、评论、文章统计值
Browse files Browse the repository at this point in the history
  • Loading branch information
HowieHz committed Jan 10, 2025
1 parent bf47ab6 commit 8548ba2
Show file tree
Hide file tree
Showing 10 changed files with 189 additions and 35 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,16 @@
4. 允许关闭页眉头像
5. 允许关闭页眉菜单
6. 允许关闭页码
7. 允许关闭页面底部主题信息
8. 允许关闭页面底部版权信息
9. 允许设定是否强制页脚在页面最底部
10. 允许关闭页面底部菜单
11. 允许添加内容到页脚最底部
12. 允许在引用块前添加引号(引用块在 Markdown 中使用 > 表示)
13. 允许在引用块后添加引号(引用块在 Markdown 中使用 > 表示)
7. 允许在站点底部显示站点统计信息
- 支持自由调整顺序、数量
- 支持选择图标/文字
8. 允许关闭页面底部主题信息
9. 允许关闭页面底部版权信息
10. 允许设定是否强制页脚在页面最底部
11. 允许关闭页面底部菜单
12. 允许添加内容到页脚最底部
13. 允许在引用块前添加引号(引用块在 Markdown 中使用 > 表示)
14. 允许在引用块后添加引号(引用块在 Markdown 中使用 > 表示)

#### 增加于“首页样式”

Expand All @@ -266,7 +269,6 @@
- 允许隐藏文章摘要
- 允许隐藏跳转文章链接所用提示文字
7. 允许自由选择是否开关文章列表置顶图标,以及选择图标位置
8. 允许在页脚展示文章发布数

#### 增加于“文章页样式”

Expand Down
68 changes: 59 additions & 9 deletions i18n-settings/settings.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,65 @@ spec:
value: true
- label: Disable
value: false
- $formkit: radio
name: is_footer_site_stats_show
label: Site statistics information at the bottom of the page
value: false
options:
- label: Enable
value: true
- label: Disable
value: false
- $formkit: repeater
name: footer_site_stats
if: "$is_footer_site_stats_show === true"
label: Statistics settings
value:
- type: "visit"
icon: ""
i18n_text: true
- type: "post"
icon: ""
i18n_text: true
- type: "upvote"
icon: ""
i18n_text: true
- type: "comment"
icon: ""
i18n_text: true
- type: "category"
icon: ""
i18n_text: true
children:
- $formkit: select
name: type
label: Statistics item
value: ""
options:
- label: "Total Views"
value: "visit"
- label: "Total number of articles"
value: "post"
- label: "Total Upvotes"
value: "upvote"
- label: "Total number of comments"
value: "comment"
- label: "Total number of categories"
value: "category"
validation: "required"
- $formkit: radio
name: i18n_text
label: Wrap text in multiple languages
value: true
options:
- value: true
label: Enable
- value: false
label: Disable
- $formkit: text
name: icon
label: Icon to the left of the text
value: ""
- $formkit: radio
name: is_footer_theme_info_show
label: Theme information in the footer
Expand Down Expand Up @@ -554,15 +613,6 @@ spec:
value: "left"
- label: "Right side of the title"
value: "right"
- $formkit: radio
name: is_show_total_published_post
label: Display the number of published posts in the footer
value: false
options:
- label: Enable
value: true
- label: Disable
value: false
- group: post_styles
label: Post page style
formSchema:
Expand Down
6 changes: 5 additions & 1 deletion i18n/default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ common.nextPage=Next Page
common.previousPage.aria-label=Go to previous page
common.nextPage.aria-label=Go to next page
common.page-number.text=Page {0} of {1}
common.siteTotalVisit=Visits {0}
common.siteTotalPost=Posts {0}
common.siteTotalUpvote=Upvotes {0}
common.siteTotalComment=Comments {0}
common.siteTotalCategory=Categories {0}

common.shareModal.clipboard.aria-label.copied=Copied!
common.shareModal.clipboard.aria-label.copy=Copy to clipboard!
Expand All @@ -17,7 +22,6 @@ page.index.postListPermalinkText=Read article
page.index.findMeLeftText=Find me on
page.index.indexPostListTitle=Writing
page.index.indexPostListPermalinkText=Read article
page.index.totalPublishedPost=Total published posts: {0}

page.archives.page-title=Archives
page.author.avatar-img.alt=Author avatar
Expand Down
6 changes: 5 additions & 1 deletion i18n/en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ common.nextPage=Next Page
common.previousPage.aria-label=Go to previous page
common.nextPage.aria-label=Go to next page
common.page-number.text=Page {0} of {1}
common.siteTotalVisit=Visits {0}
common.siteTotalPost=Posts {0}
common.siteTotalUpvote=Upvotes {0}
common.siteTotalComment=Comments {0}
common.siteTotalCategory=Categories {0}

common.shareModal.clipboard.aria-label.copied=Copied!
common.shareModal.clipboard.aria-label.copy=Copy to clipboard!
Expand All @@ -17,7 +22,6 @@ page.index.postListPermalinkText=Read article
page.index.findMeLeftText=Find me on
page.index.indexPostListTitle=Writing
page.index.indexPostListPermalinkText=Read article
page.index.totalPublishedPost=Total published posts: {0}

page.archives.page-title=Archives
page.author.avatar-img.alt=Author avatar
Expand Down
6 changes: 5 additions & 1 deletion i18n/zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ common.nextPage=下一页
common.previousPage.aria-label=前往上一页
common.nextPage.aria-label=前往下一页
common.page-number.text=第 {0} 页,共 {1} 页
common.siteTotalVisit=阅读量 {0}
common.siteTotalPost=已发布 {0}
common.siteTotalUpvote=点赞数 {0}
common.siteTotalComment=评论数 {0}
common.siteTotalCategory=分类数 {0}

common.shareModal.clipboard.aria-label.copied=已复制!
common.shareModal.clipboard.aria-label.copy=复制到剪贴板!
Expand All @@ -17,7 +22,6 @@ page.index.postListPermalinkText=阅读全文
page.index.findMeLeftText=与我联系
page.index.indexPostListTitle=近期发布
page.index.indexPostListPermalinkText=阅读全文
page.index.totalPublishedPost=已发布 {0} 篇文章

page.archives.page-title=归档
page.author.avatar-img.alt=作者头像
Expand Down
6 changes: 5 additions & 1 deletion i18n/zh_TW.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ common.nextPage=下一頁
common.previousPage.aria-label=前往上一頁
common.nextPage.aria-label=前往下一頁
common.page-number.text=第 {0} 頁,共 {1} 頁
common.siteTotalVisit=閱讀量 {0}
common.siteTotalPost=已發佈 {0}
common.siteTotalUpvote=點讚數 {0}
common.siteTotalComment=評論數 {0}
common.siteTotalCategory=分類數 {0}

common.shareModal.clipboard.aria-label.copied=已複製!
common.shareModal.clipboard.aria-label.copy=複製到剪貼簿!
Expand All @@ -17,7 +22,6 @@ page.index.postListPermalinkText=閱讀全文
page.index.findMeLeftText=與我聯繫
page.index.indexPostListTitle=近期發佈
page.index.indexPostListPermalinkText=閱讀全文
page.index.totalPublishedPost=已發佈 {0} 篇文章

page.archives.page-title=歸檔
page.author.avatar-img.alt=作者頭像
Expand Down
68 changes: 59 additions & 9 deletions settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,65 @@ spec:
value: true
- label: 关闭
value: false
- $formkit: radio
name: is_footer_site_stats_show
label: 页面底部站点统计信息
value: false
options:
- label: 开启
value: true
- label: 关闭
value: false
- $formkit: repeater
name: footer_site_stats
if: "$is_footer_site_stats_show === true"
label: 统计项设置
value:
- type: "visit"
icon: ""
i18n_text: true
- type: "post"
icon: ""
i18n_text: true
- type: "upvote"
icon: ""
i18n_text: true
- type: "comment"
icon: ""
i18n_text: true
- type: "category"
icon: ""
i18n_text: true
children:
- $formkit: select
name: type
label: 统计项
value: ""
options:
- label: "总阅读量"
value: "visit"
- label: "总文章数"
value: "post"
- label: "总点赞数"
value: "upvote"
- label: "总评论数"
value: "comment"
- label: "总分类数"
value: "category"
validation: "required"
- $formkit: radio
name: i18n_text
label: 多语言文本包裹数字
value: true
options:
- value: true
label: 开启
- value: false
label: 关闭
- $formkit: text
name: icon
label: 文字左侧的图标
value: ""
- $formkit: radio
name: is_footer_theme_info_show
label: 页面底部主题信息
Expand Down Expand Up @@ -554,15 +613,6 @@ spec:
value: "left"
- label: "标题右侧"
value: "right"
- $formkit: radio
name: is_show_total_published_post
label: 在页脚展示文章发布数
value: false
options:
- label: 开启
value: true
- label: 关闭
value: false
- group: post_styles
label: 文章页样式
formSchema:
Expand Down
6 changes: 4 additions & 2 deletions src/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,8 @@ html[data-color-scheme="dark"] article .content div.dark {
vertical-align: middle;
}

#footer li a {
#footer li a,
#footer li span {
margin-right: 0.9375rem;
}

Expand All @@ -1325,7 +1326,8 @@ html[data-color-scheme="dark"] article .content div.dark {
border-right: 0;
}

#footer li:last-child a {
#footer li:last-child a,
#footer li:last-child span {
margin-right: 0;
}

Expand Down
2 changes: 1 addition & 1 deletion templates/assets/dist/style.css

Large diffs are not rendered by default.

38 changes: 36 additions & 2 deletions templates/fragments/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,45 @@
<footer id="footer">
<div class="footer-left">
<halo:footer />
<div th:if="${theme.config?.styles?.is_footer_site_stats_show}">
<ul class="site-stats" th:with="stats = ${siteStatsFinder.getStats()}">
<li th:each="item : ${theme.config?.styles?.footer_site_stats}">
<i
class="iconify"
th:attr="data-icon=${item?.icon}"
th:if="${item?.icon != null} and ${item?.icon != ''}"
></i>
<span th:text="${stats.visit}" th:if="${item?.type=='visit'} and not ${item?.i18n_text}"></span>
<span th:text="${stats.post}" th:if="${item?.type=='post'} and not ${item?.i18n_text}"></span>
<span th:text="${stats.upvote}" th:if="${item?.type=='upvote'} and not ${item?.i18n_text}"></span>
<span th:text="${stats.comment}" th:if="${item?.type=='comment'} and not ${item?.i18n_text}"></span>
<span th:text="${stats.category}" th:if="${item?.type=='category'} and not ${item?.i18n_text}"></span>
<span
th:text="#{common.siteTotalVisit(${stats.visit})}"
th:if="${item?.type=='visit'} and ${item?.i18n_text}"
></span>
<span
th:text="#{common.siteTotalPost(${stats.post})}"
th:if="${item?.type=='post'} and ${item?.i18n_text}"
></span>
<span
th:text="#{common.siteTotalUpvote(${stats.upvote})}"
th:if="${item?.type=='upvote'} and ${item?.i18n_text}"
></span>
<span
th:text="#{common.siteTotalComment(${stats.comment})}"
th:if="${item?.type=='comment'} and ${item?.i18n_text}"
></span>
<span
th:text="#{common.siteTotalCategory(${stats.category})}"
th:if="${item?.type=='category'} and ${item?.i18n_text}"
></span>
</li>
</ul>
</div>
<div
th:if="${theme.config?.styles?.is_footer_theme_info_show} or ${theme.config?.styles?.is_footer_copyright_show}"
>
<span th:text="#{page.index.totalPublishedPost(${posts?.total})}" th:if="${posts?.total != null}"></span
><br />
<span class="info" th:if="${theme.config?.styles?.is_footer_theme_info_show}">
Theme is
<a href="https://github.com/howiehz/halo-theme-higan-hz" rel="noopener noreferrer" target="_blank"
Expand Down

0 comments on commit 8548ba2

Please sign in to comment.