hydecorp / hydejack

A boutique Jekyll theme for hackers, nerds, and academics
https://hydejack.com
Other
1.42k stars 798 forks source link

[Feature Request] Staticman comments #156

Closed oe7drt closed 5 years ago

oe7drt commented 5 years ago

Since staticman runs as a Github application I was wondering if it's planned to implement staticman or a similar comment system.

Is there a chance for a staticman implementation (or similar way to store comments on the repository)?

qwtel commented 5 years ago

I like the idea of staticman, but I don't plan on adding it to Hydejack directly.

There's an example implementation for Disqus comments in _includes/my-comments.html that you can replace with your own solution.

aaronparker commented 2 years ago

I know this thread is old and closed, but dropping by to say that this approach worked for integrating utteranc.es, in case someone else is looking to do the same.

rriemann commented 2 years ago

I can share some code. I have in my my-comments.html (credits to: https://mademistakes.com/mastering-jekyll/static-comments-improved/):

<section class="page__reactions">
  {% if site.data.comments[page.slug] %}
    <!-- Start static comments -->
    <div id="comments" class="js-comments">
      {% comment %}
      <h2 class="page__section-label">
        {% if site.data.comments[page.slug].size > 1 %}
          {{ site.data.comments[page.slug] | size }}
        {% endif %}
        Comments
      </h2>
      {% endcomment %}
      {% assign comments = site.data.comments[page.slug] | sort %}
      {% for comment in comments %}
        {% assign index       = forloop.index %}
        {% assign replying_to = comment[1].replying_to | to_integer %}
        {% assign avatar      = comment[1].avatar %}
        {% assign email       = comment[1].email %}
        {% assign name        = comment[1].name %}
        {% assign url         = comment[1].url %}
        {% assign date        = comment[1].date %}
        {% assign message     = comment[1].message %}
        {% include comment index=index replying_to=replying_to avatar=avatar email=email name=name url=url date=date message=message %}
      {% endfor %}
    </div>
    <!-- End static comments -->
  {% endif %}

  {% unless page.comments_locked == true %}
    <!-- Start new comment form -->
    <div id="respond">
      <h2 class="page__section-label">Leave a Comment <small><a rel="nofollow" id="cancel-comment-reply-link" href="{{ page.url | absolute_url }}#respond" style="display:none;">Cancel reply</a></small></h2>
      <form id="comment-form" class="page__form js-form form" method="post" action="/actions/post-comment" netlify-honeypot="age">
        <fieldset class="form-group">
          <label for="comment-form-message"><strong>Comment</strong> <small>(<a href="https://kramdown.gettalong.org/quickref.html">Markdown</a> is allowed)</small></label>
          <textarea type="text" rows="4" id="comment-form-message" name="message" required spellcheck="true" class="form-control"></textarea>
        </fieldset>
        <div class="form-row">
          <fieldset class="form-group col-md-6">
            <label for="comment-form-name" class="col-form-label"><strong>Name</strong></label>
              <input type="text" id="comment-form-name" class="form-control" name="name" required spellcheck="false">
          </fieldset>
          <fieldset class="form-group col-md-6">
            <label for="comment-form-url" class="col-form-label"><strong>Website</strong> <small>(optional)</small></label>
            <input type="url" id="comment-form-url" class="form-control" name="url"/>
          </fieldset>
        </div>
        <fieldset class="form-group">
          <label for="comment-form-email" class="col-form-label"><strong>Email</strong> <small>(used for <a href="http://gravatar.com">Gravatar</a> image)</small></label>
          <input type="email" id="comment-form-email" class="form-control" name="email" required spellcheck="false">
        </fieldset>
        <fieldset style="display: none;">
          <input type="hidden" name="origin" value="{{ page.url | absolute_url }}">
          <input type="hidden" name="title" value="{{ page.title }}">
          <input type="hidden" id="comment-replying-to" name="replying_to" value="">
          <input type="hidden" id="comment-post-id" name="slug" value="{{ page.slug }}">
          <label for="comment-form-location">Leave blank if you are a human</label>
          <input type="text" id="comment-form-location" name="age" autocomplete="off">
        </fieldset>
        <button type="submit" id="comment-form-submit" class="btn btn-primary">Submit Comment</button>
      </form>
    </div>
    <!-- End new comment form -->
  {% else %}
    <p><em>Comments are closed. If you have a question concerning the content of this page, please feel free to <a href="/about/#contact">contact me</a>.</em></p>
  {% endunless %}
</section>

It's geared towards threaded replies, but does not support it currently. I posted about my move away from Disqus and Disqus data export here: https://blog.riemann.cc/2021/12/27/jekyll-import-disqus-comments-for-staticman/