Add configurable comment links section

This commit is contained in:
timvisee 2021-02-27 18:15:04 +01:00
parent a3d2d86d2c
commit 55f912995e
No known key found for this signature in database
GPG Key ID: B8DB720BC383E172
3 changed files with 33 additions and 1 deletions

View File

@ -7,8 +7,12 @@ categories = ["blog"]
tags = ["rust", "performance", "aoc"]
[extra]
comments = true
zenn_applause = true
comments = [
{url = "https://news.ycombinator.org/", name = "Hackernews"},
{url = "https://reddit.com/", name = "Reddit"},
{url = "https://lobste.rs/", name = "Lobsters"},
]
+++
```

View File

@ -17,11 +17,34 @@
{{ page.content | safe }}
</div>
{# Comments header #}
{% if page.extra.comments %}
<h2 id="comments">Comments</h2>
{% endif %}
{# Applause button #}
{% if page.extra.zenn_applause %}
<div class="applause-wrapper">
<applause-button color="#a6a28c" url="{{ page.permalink | safe }}"></applause-button>
</div>
{% endif %}
{# Comments #}
{% if page.extra.comments %}
<p>
Comments on
{% for page in page.extra.comments %}
<a href="{{ page.url | safe }}" target="_blank">{{ page.name }}</a>
{%- if not loop.last -%}
{% if loop.index == page.extra.comments | length - 1%}
&amp;
{% else -%}
,
{% endif %}
{% endif %}
{% endfor %}
</p>
{% endif %}
</article>
{% endblock body %}

View File

@ -190,6 +190,11 @@
{% endif %}
</li>
{% endfor %}
{# Comments link #}
{% if page.extra.comments %}
<li><a href="#comments" title="Comments">Comments</a></li>
{% endif %}
</ul>
</section>
{%- endif %}