Skip to content

Commit

Permalink
fix: comment support for pages
Browse files Browse the repository at this point in the history
  • Loading branch information
not-matthias committed Oct 20, 2024
1 parent 4d3e2d2 commit a7aa3b9
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 22 deletions.
1 change: 0 additions & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ toc = true
use_cdn = false
favicon = "/icon/favicon.png"
theme = "toggle" # light, dark, auto, toggle
comment = false
fancy_code = true
dynamic_note = true # a note that can be toggled
mathjax = true
Expand Down
3 changes: 3 additions & 0 deletions content/posts/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ title = "Posts"
sort_by = "date"

insert_anchor_links = "heading"

[extra]
comment = true
+++
61 changes: 44 additions & 17 deletions content/posts/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ tags=["documentation"]

[extra]
repo_view = true
comment = true
+++

# Site Configuration

## Theme Mode (`theme`)

Sets the color theme for your blog.
Expand All @@ -20,7 +23,7 @@ Sets the color theme for your blog.

The "toggle" option allows users to switch between light and dark modes, while "auto" typically follows the user's system preferences.

## Menu
## Menu

Defines the navigation menu items for your blog.

Expand All @@ -38,7 +41,7 @@ Defines the navigation menu items for your blog.

## Socials

Defines the social media links.
Defines the social media links.

- Type: Array of objects
- Default: []
Expand Down Expand Up @@ -80,18 +83,6 @@ Specifies the path to the favicon image for your blog.

This sets the small icon that appears in the browser tab for your website.

## Comments (`comment`)

Enables or disables the comment system for posts.

- Type: Boolean
- Default: false
- Usage: `comment = false`

After making `comment = true` save your script from [Giscus](https://giscus.app) to `templates/_giscus_script.html`.
When enabled, this allows readers to leave comments on your blog posts.


## Fancy Code Styling (`fancy_code`)

Enables enhanced styling for code blocks.
Expand All @@ -112,6 +103,17 @@ Allows for the creation of togglable note sections in your content.

When enabled, you can create expandable/collapsible note sections in your blog posts.

## Anchor Links

You can add anchor links by adding the following to your `_index.md`:
```toml
insert_anchor_links = "heading"
```

# Page configuration



## Source code (`repo_view`)

Do you want to link to the source code of your blog post? You can turn on the `repo_view` inside the `[extra]` section of your blog post.
Expand All @@ -124,9 +126,34 @@ repo_url = "https://github.com/not-matthias/apollo/tree/main/content" # Altern

The `repo_url` can be set in the `[extra]` section or in your `config.toml`.

## Anchor Links
## Comments (`comment`)

You can add anchor links by adding the following to your `_index.md`:
Enables or disables the comment system for posts.

- Type: Boolean
- Default: false
- Usage: `comment = false`

After making `comment = true` in `[extra]` section of you post, save your script from [Giscus](https://giscus.app) to `templates/_giscus_script.html`.
When enabled, this allows readers to leave comments on your blog posts. This feature has to be set for each individual post and is not supported at higher levels.

Example configuration in [content/posts/configuration.md](https://github.com/not-matthias/apollo/blob/main/content/posts/configuration.md):
```toml
insert_anchor_links = "heading"
+++
title = "Configuring Apollo"

[extra]
comment = true
+++
```

Comments via [utterances](utteranc.es) can be configured in `template/_giscus_script.html` like this:
```html
<script src="https://utteranc.es/client.js"
repo="not-matthias/apollo"
issue-term="pathname"
theme="github-light"
crossorigin="anonymous"
async>
</script>
```
5 changes: 4 additions & 1 deletion content/posts/markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ updated = "2022-05-01"

[taxonomies]
tags=["example"]

[extra]
comment = true
+++

# H1
Expand Down Expand Up @@ -80,5 +83,5 @@ fn main() {

## Code tags

Lorem ipsum `dolor` sit amet, `consectetur adipiscing` elit.
Lorem ipsum `dolor` sit amet, `consectetur adipiscing` elit.
`Lorem ipsum dolor sit amet, consectetur adipiscing elit.`
3 changes: 3 additions & 0 deletions content/posts/math-symbol.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ date = "2023-01-06"

[taxonomies]
tags=["example"]

[extra]
comment = true
+++

Note: This requires the `mathjax` and `mathjax_dollar_inline_enable` option set to `true`.
Expand Down
5 changes: 4 additions & 1 deletion content/posts/shortcode.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ date = "2024-06-14"

[taxonomies]
tags=["example"]

[extra]
comment = true
+++


## Note

Here is an example of the `note` shortcode:

This one is static!
Expand Down
7 changes: 7 additions & 0 deletions templates/_giscus_script.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script src="https://utteranc.es/client.js"
repo="not-matthias/apollo"
issue-term="pathname"
theme="github-light"
crossorigin="anonymous"
async>
</script>
9 changes: 7 additions & 2 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@
Nothing here?!
{% endblock main_content %}

{% if config.extra.comment | default(value=false) %}
{% if page.extra.comment is defined %}
{% set show_comment = page.extra.comment %}
{% else %}
{% set show_comment = false %}
{% endif %}

{% if show_comment %}
<div class="giscus"></div>
{% include "_giscus_script.html" %}
{% endif %}

</div>
</body>

Expand Down

0 comments on commit a7aa3b9

Please sign in to comment.