|
1 | | -<!-- unnecessary file, however you can still use for comment section, e.g disqus --> |
2 | | -<script |
3 | | - src="https://utteranc.es/client.js" |
4 | | - repo="username/reponame" |
5 | | - issue-term="pathname" |
6 | | - label="✨ comment ✨" |
7 | | - theme="github-light" |
8 | | - crossorigin="anonymous" |
9 | | - async |
10 | | -></script> |
| 1 | +{% assign giscus_repo = site.giscus.repo | strip %} |
| 2 | +{% assign giscus_repo_id = site.giscus.repo_id | strip %} |
| 3 | +{% assign giscus_category = site.giscus.category | strip %} |
| 4 | +{% assign giscus_category_id = site.giscus.category_id | strip %} |
| 5 | + |
| 6 | +{% assign giscus_configured = false %} |
| 7 | +{% if giscus_repo != empty and giscus_repo_id != empty and giscus_category != empty and giscus_category_id != empty %} |
| 8 | + {% assign giscus_configured = true %} |
| 9 | +{% endif %} |
| 10 | + |
| 11 | +{% assign missing_giscus_fields = "" | split: "," %} |
| 12 | +{% if giscus_repo == empty %} |
| 13 | + {% assign missing_giscus_fields = missing_giscus_fields | push: "repo" %} |
| 14 | +{% endif %} |
| 15 | +{% if giscus_repo_id == empty %} |
| 16 | + {% assign missing_giscus_fields = missing_giscus_fields | push: "repo_id" %} |
| 17 | +{% endif %} |
| 18 | +{% if giscus_category == empty %} |
| 19 | + {% assign missing_giscus_fields = missing_giscus_fields | push: "category" %} |
| 20 | +{% endif %} |
| 21 | +{% if giscus_category_id == empty %} |
| 22 | + {% assign missing_giscus_fields = missing_giscus_fields | push: "category_id" %} |
| 23 | +{% endif %} |
| 24 | + |
| 25 | +<section class="comments"> |
| 26 | + {% if giscus_configured %} |
| 27 | + <div class="giscus"></div> |
| 28 | + <script src="https://giscus.app/client.js" |
| 29 | + data-repo="{{ giscus_repo }}" |
| 30 | + data-repo-id="{{ giscus_repo_id }}" |
| 31 | + data-category="{{ giscus_category }}" |
| 32 | + data-category-id="{{ giscus_category_id }}" |
| 33 | + data-mapping="{{ site.giscus.mapping | default: 'pathname' }}" |
| 34 | + data-strict="{{ site.giscus.strict | default: 0 }}" |
| 35 | + data-reactions-enabled="{{ site.giscus.reactions_enabled | default: 1 }}" |
| 36 | + data-emit-metadata="{{ site.giscus.emit_metadata | default: 0 }}" |
| 37 | + data-input-position="{{ site.giscus.input_position | default: 'bottom' }}" |
| 38 | + data-theme="{{ site.giscus.theme | default: 'preferred_color_scheme' }}" |
| 39 | + data-lang="{{ site.giscus.lang | default: site.lang | default: 'en' }}" |
| 40 | + data-loading="{{ site.giscus.loading | default: 'lazy' }}" |
| 41 | + crossorigin="anonymous" |
| 42 | + async> |
| 43 | + </script> |
| 44 | + {% else %} |
| 45 | + <div class="comments-warning" role="alert" aria-live="polite"> |
| 46 | + <strong>Comments are unavailable.</strong> |
| 47 | + Configure Giscus in <code>_config.yml</code>. Missing field{% if missing_giscus_fields.size != 1 %}s{% endif %}: |
| 48 | + <code>{{ missing_giscus_fields | join: ", " }}</code> |
| 49 | + </div> |
| 50 | + {% endif %} |
| 51 | +</section> |
0 commit comments