Skip to content

Commit

Permalink
feat: added comment giscus support
Browse files Browse the repository at this point in the history
  • Loading branch information
danieltomasz committed Aug 5, 2023
1 parent 599a9fc commit 3307d52
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 29 deletions.
1 change: 1 addition & 0 deletions .vscode/ltex.dictionary.en-GB.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
MISMaP
metascience
Borek
giscus
1 change: 1 addition & 0 deletions .vscode/ltex.disabledRules.en-GB.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
OXFORD_SPELLING_Z_NOT_S
MORFOLOGIK_RULE_EN_GB
32 changes: 18 additions & 14 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,24 @@ theme = 'lines'
logo = ""
orgName = "Daniel Borek"
orgLocal = ""
disableComments = false

[params.giscus]
repo="danieltomasz/danieltomasz.github.io"
repo-id="MDEwOlJlcG9zaXRvcnkzMzM0MDUzMzY="
category="Comments"
category-id="DIC_kwDOE99cmM4CVDXo"
mapping="title"
strict="0"
reactions-enabled="1"
emit-metadata="1"
input-position="bottom"
theme="light"
lang="en"
loading="lazy"
crossorigin="anonymous"
reactionsEnabled = "1"


[frontmatter]
date = [":filename", ":default", "lastmod"]
Expand Down Expand Up @@ -124,17 +142,3 @@ ignoreFiles = [ "\\.qmd$", "\\.ipynb$", "\\.py$" ]
name = "twitter"
link = "https://www.twitter.com/danieltomasz"

[params.giscus]
data-repo="danieltomasz/danieltomasz.github.io"
data-repo-id="MDEwOlJlcG9zaXRvcnkzMzM0MDUzMzY="
data-category="Comments"
data-category-id="DIC_kwDOE99cmM4CVDXo"
data-mapping="title"
data-strict="0"
data-reactions-enabled="1"
data-emit-metadata="1"
data-input-position="top"
data-theme="light"
data-lang="en"
data-loading="lazy"
crossorigin="anonymous"
2 changes: 2 additions & 0 deletions content/pages/about.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: About
noComment: true
---
## Daniel Borek

I studied physics within a MISMaP interdisciplinary programme and philosophy at University of Warsaw.

Expand Down
23 changes: 22 additions & 1 deletion content/posts/back to hugo.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,25 @@ I try this setting within the markup section,

### Rendering mermaid diagrams

Paul Johnson describe his setup in [ this blogpost](https://www.paulrjohnson.net/2022/09/rendering-mermaid-diagrams-on-a-hugo-website-using-quarto/).
Paul Johnson describe his setup in [ this blogpost](https://www.paulrjohnson.net/2022/09/rendering-mermaid-diagrams-on-a-hugo-website-using-quarto/).


### Adding comments with `giscus`

I followed various blogpost with the configuration advices.
By default, `giscus` is adding comments to every page, but I wanted to have comments only on my posts.
I followed advice[^1] and I wrapped my addition of `giscus` partial into `footer.html` with `if` statement:

```hugo
{{ if not .Params.noComment }}
{{ partial "giscus" . }}
{{ end }}
```

When I don't want to include a comments block, I am adding this in the frontmatter of the post (yaml):

```yaml
noComment: true
```
[^1]: [How to disable comments in specific pages? - support - HUGO](https://discourse.gohugo.io/t/how-to-disable-comments-in-specific-pages/22177/2)
11 changes: 11 additions & 0 deletions content/posts/learning-hugo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: "Learning Hugo"
date: "2023-08-03"
draft: true
tags:
- Quatro
- Hugo
---

Customization of the site
[Context And Variables In The Hugo Static Site Generator — Smashing Magazine](https://www.smashingmagazine.com/2021/02/context-variables-hugo-static-site-generator/)
25 changes: 25 additions & 0 deletions layouts/_default/list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!doctype html>
<html lang="en">
{{ partial "head.html" . }}
<body>
<main>
{{ partial "header.html" . }}
<section>

<ul class="posts">
{{ range (.Paginate ( where .Site.RegularPages "Section" "posts" ).ByDate.Reverse).Pages }}
{{ if ne .Kind "section" }}
<li itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
<a href="{{ .Permalink }}" title="{{ .Title }}" itemprop="name url">{{ .Title }}</a>
<hr>
<time datetime="{{ dateFormat "2006-01-02" .Date }}">{{ dateFormat "2006-01-02" .Date }}</time>
</li>
{{ end }}
{{ end }}
</ul>
</section>

{{ partial "footer.html" . }}
</main>
</body>
</html>
2 changes: 1 addition & 1 deletion layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h2 itemprop="name headline">{{ .Title }}</h2>


</section>
{{ partial "footer.html" . }}
{{ partial "footer_giscus.html" . }}
</main>
</body>

13 changes: 0 additions & 13 deletions layouts/partials/footer.html

This file was deleted.

17 changes: 17 additions & 0 deletions layouts/partials/footer_giscus.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<hr>

<footer>

{{ if not .Params.noComment }}
{{ partial "giscus" . }}
{{ end }}

<nav>
<ul>
<li>
© {{ dateFormat "2006" now }}
</li>
</ul>
</nav>

</footer>

0 comments on commit 3307d52

Please sign in to comment.