From 41c076538071afda630873615a5cca656d6cc1ea Mon Sep 17 00:00:00 2001
From: "welcomments[bot]" <54233877+welcomments[bot]@users.noreply.github.com>
Date: Sat, 20 Mar 2021 21:00:44 +0000
Subject: [PATCH] Add Welcomments for better static site comments.
---
_includes/welcomments/comment_form.html | 26 ++++++
_includes/welcomments/comments.html | 109 ++++++++++++++++++++++
_includes/welcomments/single_comment.html | 57 +++++++++++
_includes/welcomments/template.html | 43 +++++++++
4 files changed, 235 insertions(+)
create mode 100644 _includes/welcomments/comment_form.html
create mode 100644 _includes/welcomments/comments.html
create mode 100644 _includes/welcomments/single_comment.html
create mode 100644 _includes/welcomments/template.html
diff --git a/_includes/welcomments/comment_form.html b/_includes/welcomments/comment_form.html
new file mode 100644
index 0000000..d0d7a78
--- /dev/null
+++ b/_includes/welcomments/comment_form.html
@@ -0,0 +1,26 @@
+
\ No newline at end of file
diff --git a/_includes/welcomments/comments.html b/_includes/welcomments/comments.html
new file mode 100644
index 0000000..f17af6a
--- /dev/null
+++ b/_includes/welcomments/comments.html
@@ -0,0 +1,109 @@
+{%- if include.api_url -%}
+ {%- assign api_url = include.api_url -%}
+{%- else -%}
+ {%- assign api_url = "https://welcomments.io/api" -%}
+{%- endif -%}
+
+{%- if include.website_id == "YOUR-WEBSITE-ID-HERE" -%}
+
+
Website id not configured!
+
Please replace YOUR-WEBSITE-ID-HERE
with the website id from Welcomments console.
+
+{%- endif -%}
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/_includes/welcomments/single_comment.html b/_includes/welcomments/single_comment.html
new file mode 100644
index 0000000..82f867d
--- /dev/null
+++ b/_includes/welcomments/single_comment.html
@@ -0,0 +1,57 @@
+{%- assign nesting_level = include.nesting_level -%}
+{%- assign all_comments = include.all_comments -%}
+{%- assign comment = include.comment -%}
+
+{%- assign nesting_level_class = "" -%}
+{%- if nesting_level > 0 -%}
+ {% capture nesting_level_class %} welcomments__nesting-level-{{ nesting_level }}{% endcapture %}
+{%- endif -%}
+
+{%- assign author_highlight = "" -%}
+{%- if comment.author.role == "owner" -%}
+ {% capture author_highlight %} welcomments__comment-role-owner{% endcapture %}
+{%- endif -%}
+
+{%- capture comment_element_id -%}welcomments__comment-{{ comment.id }}{%- endcapture -%}
+{%- capture comment_element_class -%}welcomments__comment{{nesting_level_class}}{{ author_highlight }}{%- endcapture -%}
+
+{%- capture formatted_date -%}{{ comment.date | date: '%B %d, %Y' }}{%- endcapture -%}
+{%- capture date_xml_schema -%}{{ comment.date | date_to_xmlschema }}{%- endcapture -%}
+{%- capture comment_message -%}{{ comment.message | markdownify }}{%- endcapture -%}
+
+{% if comment.author.avatar_url %}
+ {% capture author_avatar_url %}{{ comment.author.avatar_url }}{% endcapture %}
+{% else %}
+ {% capture author_avatar_url %}https://eu.ui-avatars.com/api/?background=random&name={{ comment.author.name }}{% endcapture %}
+{% endif %}
+
+{%- include welcomments/template.html
+ id = comment.id
+ element_id = comment_element_id
+ element_classname = comment_element_class
+ nesting_level = nesting_level
+ formatted_date = formatted_date
+ date_xml_schema = date_xml_schema
+ author_name = comment.author.name
+ author_website = comment.author.website
+ author_avatar_url = author_avatar_url
+ message = comment_message
+ api_url = include.api_url
+ website_id = include.website_id -%}
+
+{%- assign parent_id = comment.id -%}
+{%- assign replies = all_comments | where_exp: "c", "c.replying_to == parent_id" -%}
+
+{%- if replies.size > 0 -%}
+ {%- assign nesting_level = nesting_level | plus:1 -%}
+ {%- assign sorted_replies = replies | sort: 'id' -%}
+ {%- for reply in sorted_replies -%}
+ {%- include
+ welcomments/single_comment.html
+ nesting_level = nesting_level
+ all_comments = all_comments
+ comment = reply
+ api_url = include.api_url
+ website_id = include.website_id -%}
+ {%- endfor -%}
+{%- endif -%}
\ No newline at end of file
diff --git a/_includes/welcomments/template.html b/_includes/welcomments/template.html
new file mode 100644
index 0000000..3c38967
--- /dev/null
+++ b/_includes/welcomments/template.html
@@ -0,0 +1,43 @@
+{%- assign id = include.id -%}
+{%- assign element_id = include.element_id -%}
+{%- assign element_classname = include.element_classname -%}
+{%- assign nesting_level = include.nesting_level -%}
+{%- assign formatted_date = include.formatted_date -%}
+{%- assign date_xml_schema = include.date_xml_schema -%}
+{%- assign author_name = include.author_name -%}
+{%- assign author_website = include.author_website -%}
+{%- assign avatar_url = include.author_avatar_url -%}
+{%- assign message = include.message -%}
+
+
+
+
+
+
\ No newline at end of file
{{ all_comments.size }} comment{%- if all_comments.size > 1 -%}s{%- endif -%}
+ {%- else -%} +No comments yet!
+ {%- endif -%} + +