-
I would like to add a section in the Adding a comment system page to explain how to integrate Giscus an open-source alternative. With that said do I currently encounter some minor issues, which I'm not sure how best to solve for this... The biggest issue is, that the Javascript giscus uses requires the ids of repository and category which require the usage of the giscus page to retrieve. My goal with the edit however is, to provide a guide that would allow customizing the comment system per-page similar to Disqus, but with all the options can I not think of an easy way to achieve this, so I would like to use this discussion as a way to "brainstorm" possible ideas. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I currently have this idea here, but I'm unsure if that would be the best approach: <!--
Copyright (c) 2016-2021 Martin Donath <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
-->
<!-- Edit button -->
{% if page.edit_url %}
<a
href="{{ page.edit_url }}"
title="{{ lang.t('edit.link.title') }}"
class="md-content__button md-icon"
>
{% include ".icons/material/pencil.svg" %}
</a>
{% endif %}
<!--
Hack: check whether the content contains a h1 headline. If it
doesn't, the page title (or respectively site name) is used
as the main headline.
-->
{% if not "\x3ch1" in page.content %}
<h1>{{ page.title | d(config.site_name, true)}}</h1>
{% endif %}
<!-- Markdown content -->
{{ page.content }}
<!-- Source file information -->
{% if page and page.meta and (
page.meta.git_revision_date_localized or
page.meta.revision_date
) %}
{% include "partials/source-file.html" %}
{% endif %}
{% set giscus_repo = config.extra.giscus.repo %}
{% set giscus_repo_id = config.extra.giscus.repo_id %}
{% set giscus_category = config.extra.giscus.category %}
{% set giscus_category_id = config.extra.giscus.category_id %}
{% set giscus_mapping = config.extra.giscus.mapping %}
{% set giscus_reaction = config.extra.giscus.reaction %}
{% set giscus_metadata = config.extra.giscus.metadata %}
{% set giscus_theme = config.extra.giscus.theme %}
{% set giscus_language = config.extra.giscus.language %}
{% if page and page.meta and page.meta.giscus.repo is string %}
{% set giscus_repo = page.meta.giscus.repo %}
{% endif %}
{% if page and page.meta and page.meta.giscus.repo_id is string %}
{% set giscus_repo_id = page.meta.giscus.repo_id %}
{% endif %}
{% if page and page.meta and page.meta.giscus.category is string %}
{% set giscus_category = page.meta.giscus.category %}
{% endif %}
{% if page and page.meta and page.meta.giscus.category_id is string %}
{% set giscus_category_id = page.meta.giscus.category_id %}
{% endif %}
{% if page and page.meta and page.meta.giscus.mapping is string %}
{% set giscus_mapping = page.meta.giscus.mapping %}
{% endif %}
{% if page and page.meta and page.meta.giscus.reaction is string %}
{% set giscus_reaction = page.meta.giscus.reaction %}
{% endif %}
{% if page and page.meta and page.meta.giscus.metadata is string %}
{% set giscus_metadata = page.meta.giscus.metadata %}
{% endif %}
{% if page and page.meta and page.meta.giscus.theme is string %}
{% set giscus_theme = page.meta.giscus.theme %}
{% endif %}
{% if page and page.meta and page.meta.giscus.language is string %}
{% set giscus_language = page.meta.giscus.language %}
{% endif %}
{% if not page.is_homepage and giscus_repo %}
<h2 id="__comments">
<span class="twemoji">
{% include ".icons/octicons/comment-discussion-24.svg" %}
</span>
{{ lang.t("meta.comments") }}
</h2>
<div id="giscus-thread"></div>
<script src="https://giscus.app/client.js"
data-repo="{{ giscus_repo }}"
data-repo-id="{{ giscus_repo_id }}"
data-category="{{ giscus_category }}"
data-category-id="{{ giscus_category_id }}"
data-mapping="{{ giscus_mapping }}"
data-reactions-enabled="{{ giscus_reaction }}"
data-emit-metadata="{{ giscus_metadata }}"
data-theme="{{ giscus_theme }}"
data-lang="{{ giscus_language }}"
crossorigin="anonymous"
async>
</script>
{% endif %} |
Beta Was this translation helpful? Give feedback.
-
I for now made a PR, so any suggestions and ideas should be made there: #3329 |
Beta Was this translation helpful? Give feedback.
I for now made a PR, so any suggestions and ideas should be made there: #3329