From f96aff16a539b560247d0e6bd3364e5cb5787d77 Mon Sep 17 00:00:00 2001 From: Dong Hao Date: Mon, 26 Feb 2024 18:20:02 +0400 Subject: [PATCH] add support for comment from giscus.app --- README.md | 11 +++++++++++ config.toml | 3 ++- templates/base.html | 7 ++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6a129a40..7d4af169 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,17 @@ cp -r themes/apollo/content content ## Options +### Comment + +You can enable comment (Giscus) for each page: + +```toml +[extra] +comment = true +``` + +And then save your script from [Giscus](https://giscus.app) to `templates/_giscus_script.html`. + ### Additional stylesheets You can add stylesheets to override the theme: diff --git a/config.toml b/config.toml index c8e2ed2a..4e41ff6d 100644 --- a/config.toml +++ b/config.toml @@ -14,6 +14,7 @@ toc = true use_cdn = false favicon = "/icon/favicon.png" theme = "toggle" # light, dark, auto, toggle +comment = false # mathjax = true # mathjax_dollar_inline_enable = true @@ -39,4 +40,4 @@ host = "example.com" # default= goatcounter.com [extra.analytics.umami] website_id = "43929cd1-1e83...." -host_url = "https://stats.mywebsite.com" # default: https://analytics.eu.umami.is \ No newline at end of file +host_url = "https://stats.mywebsite.com" # default: https://analytics.eu.umami.is diff --git a/templates/base.html b/templates/base.html index aad8faf7..c67c1d26 100644 --- a/templates/base.html +++ b/templates/base.html @@ -13,7 +13,12 @@ {% block main_content %} Nothing here?! {% endblock main_content %} + {% if page.extra.comment is defined %}{% set show_comment = page.extra.comment %}{% else %}{% set show_comment = config.extra.comment %}{% endif %} + {% if show_comment %} +
+ {% include "_giscus_script.html" %} + {% endif %} - \ No newline at end of file +