Github:https://github.com/Hyun-Soon/Hyun-Soon.github.io
我正在尝试用 jekyll 最小错误主题制作博客。
我这样写了_config.yml,但我在帖子中看不到 giscus。
comments:
provider : giscus # false (default), "disqus", "discourse", "facebook", "staticman", "staticman_v2", "utterances", "giscus", "custom"
disqus:
shortname : # https://help.disqus.com/customer/portal/articles/466208-what-s-a-shortname-
discourse:
server : # https://meta.discourse.org/t/embedding-discourse-comments-via-javascript/31963 , e.g.: meta.discourse.org
facebook:
# https://developers.facebook.com/docs/plugins/comments
appid :
num_posts : # 5 (default)
colorscheme : # "light" (default), "dark"
utterances:
theme : # "github-light" (default), "github-dark"
issue_term : # "pathname" (default)
giscus:
repo_id : "R_kgDOKeOOEA" # Shown during giscus setup at https://giscus.app
category_name : "Comments" # Full text name of the category
category_id : "DIC_kwDOKeOOEM4CaKQd" # Shown during giscus setup at https://giscus.app
discussion_term : "pathname" # "pathname" (default), "url", "title", "og:title"
reactions_enabled : "1" # '1' for enabled (default), '0' for disabled
theme : "dark_dimmed" # "light" (default), "dark", "dark_dimmed", "transparent_dark", "preferred_color_sc
如果我直接将此代码写入 md 文件,我可以在帖子中看到 giscus 评论框
<script src="https://giscus.app/client.js"
data-repo="Hyun-Soon/Hyun-Soon.github.io"
data-repo-id="R_kgDOKeOOEA"
data-category="Comments"
data-category-id="DIC_kwDOKeOOEM4CaKQd"
data-mapping="pathname"
data-strict="0"
data-reactions-enabled="1"
data-emit-metadata="0"
data-input-position="bottom"
data-theme="dark_dimmed"
data-lang="ko"
crossorigin="anonymous"
async>
</script>
我尝试搜索多个有关此问题的帖子,但它们都只是修改 _config.yml 并成功进行 giscus 评论。 请帮助我
如果你阅读 giscus.html,你会看到这个:
<script>
'use strict';
(function () {
var commentContainer = document.querySelector('#giscus-comments');
if (!commentContainer) {
return;
}
var script = document.createElement('script');
script.setAttribute('src', 'https://giscus.app/client.js');
script.setAttribute('data-repo', '{{ site.repository | downcase }}');
script.setAttribute('data-repo-id', '{{ site.comments.giscus.repo_id }}');
script.setAttribute('data-category', '{{ site.comments.giscus.category_name }}');
script.setAttribute('data-category-id', '{{ site.comments.giscus.category_id }}');
script.setAttribute('data-mapping', '{{ site.comments.giscus.discussion_term | default: "pathname" }}');
script.setAttribute('data-reactions-enabled', '{{ site.comments.giscus.reactions_enabled | default: 1 }}');
script.setAttribute('data-theme', '{{ site.comments.giscus.theme | default: "light" }}');
script.setAttribute('crossorigin', 'anonymous');
commentContainer.appendChild(script);
})();
</script>
所以你需要填写config.yaml中的“存储库”,然后填写注释。
repository : "user/rope"
...
comments:
provider : "giscus"
...
single.html 显示:
{% if jekyll.environment == 'production' and site.comments.provider and page.comments %}
{% include comments.html %}
{% endif %}
{% endraw %}
确保启用 jekyll.environment == '生产',
在 Windows 中使用 $env:JEKYLL_ENV="product",
或者在linux中导出JEKYLL_ENV=生产。