From 5c68750e0cd265464aa55b1f1d89e54f7e71ccc0 Mon Sep 17 00:00:00 2001 From: amzrk2 Date: Thu, 18 Jun 2020 14:17:51 +0800 Subject: Optimize toc & license settings logic --- README.md | 25 +++++++++++++++---------- README_CN.md | 25 +++++++++++++++---------- layouts/_default/single.html | 2 +- layouts/partials/sidebar.html | 8 +++++--- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index a7e8a05..e943603 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Now supported i18n langs: en, zh-hans, zh-hant, ja, nl. Check the i18n folder to - [🆕 Update the theme](#-update-the-theme) - [⚙️ Configuration](#%EF%B8%8F-configuration) - [🎨 Favicon](#-favicon) - - [❌ In-post license, comments und toc](#-in-post-license-comments-und-toc) + - [❌ License, toc und comments](#-license-toc-und-comments) - [🎵 APlayer](#-aplayer) - [📷 Image zoom and lazyload settings](#-image-zoom-and-lazyload-settings) - [⚓ Markdown render hook](#-markdown-render-hook) @@ -30,7 +30,7 @@ Now supported i18n langs: en, zh-hans, zh-hant, ja, nl. Check the i18n folder to ## 💻 Live demos -[**Live Demo by Vercel (en)**](https://hugo-theme-fuji-demo.now.sh/) | [My Blog by Coding (zh-Hans)](https://blog.amzrk2.cc/) +[**Live Demo (en)**](https://hugo-theme-fuji-demo.now.sh/) | [My Blog (zh-Hans)](https://blog.amzrk2.cc/)  @@ -76,21 +76,26 @@ Create `[SITEROOT]/layouts/partials/favicon.html` to cover theme's favicon. You can generate your favicons in [realfavicongenerator.net](https://realfavicongenerator.net/). -### ❌ In-post license, comments und toc +### ❌ License, toc und comments -You can set variables below in post's front matter to disable them: +Globally in `config.toml`: ```toml -noLicense = true # Do not show license in this post -noComments = true # Do not show comments in this post -noToc = true # Do not show toc in this post +showLicense = true # Enable or disable license for all post +showToc = true # Enable or disable ToC for all post +``` + +Or in posts' front matter: + +```toml +showLicense = true # Enable or disable license for this specific post +showToc = true # Enable or disable ToC for this specific post ``` -Or you can disable these globally, set these below to false or comment it in your `config.toml`: +To disable comment area for specific post, add this in front matter: ```toml -showLicense = false -showToc = false +noComments = true # Do not show comments in this post ``` ### 🎵 APlayer diff --git a/README_CN.md b/README_CN.md index 17fe0c0..75d1c86 100644 --- a/README_CN.md +++ b/README_CN.md @@ -18,7 +18,7 @@ - [🆕 更新主题](#-更新主题) - [⚙️ 自定义设置](#%EF%B8%8F-自定义设置) - [🎨 站点图标](#-站点图标) - - [❌ 关闭 License、评论区和目录](#-关闭-license评论区和目录) + - [❌ License、目录和评论区](#-license目录和评论区) - [🎵 文章音乐](#-文章音乐) - [📷 图片放大的设置和 lazyload](#-图片放大的设置和-lazyload) - [⚓ Markdown 钩子](#-markdown-钩子) @@ -30,7 +30,7 @@ ## 💻 在线 Demo -[**在线 Demo - Vercel (英文)**](https://hugo-theme-fuji-demo.now.sh/) | [我的博客 - Coding (中文)](https://blog.amzrk2.cc/) +[**在线 Demo (英文)**](https://hugo-theme-fuji-demo.now.sh/) | [我的博客 (中文)](https://blog.amzrk2.cc/)  @@ -66,21 +66,26 @@ $ git submodule update --remote --merge 可以在 [realfavicongenerator.net](https://realfavicongenerator.net/) 快速创建自己的图标。 -### ❌ 关闭 License、评论区和目录 +### ❌ License、目录和评论区 -在 front matter 里加上这些: +在全局的 `config.toml` 里设置: ```toml -noLicense = true # 憋显示 License -noComments = true # 憋显示评论区 -noToc = true # 憋显示目录 +showLicense = true # 对所有文章开关 License 显示 +showToc = true # 对所有文章开关目录显示 ``` -你也可以全局关闭这些内容的显示,在 `config.toml` 把下面这些设置为 false 或注释掉: +在特定文章的 front matter 里设置: ```toml -showLicense = false -showToc = false +showLicense = true # 对这篇文章开关 License 显示 +showToc = true # 对这篇文章开关目录显示 +``` + +除此之外你也可以关闭特定文章的评论: + +```toml +noComments = true # 对这篇文章关闭评论 ``` ### 🎵 文章音乐 diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 413cacc..26a8213 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -16,7 +16,7 @@ -{{ if and (.Site.Params.showLicense) (ne .Params.noLicense true) }} +{{ if and (or .Site.Params.showLicense .Params.showLicense) (ne .Params.showLicense false) }}