Nested replies

This commit is contained in:
Lewis Dale 2024-01-05 13:48:15 +00:00
parent db54ca40c6
commit d0542271a0
2 changed files with 21 additions and 16 deletions

View File

@ -0,0 +1,13 @@
{% macro reply(note) %}
<div>
<time class="dt-published" datetime="{{ note.createdAt | dateToRfc3339 }}">{{ note.createdAt | dateTimeDisplay }}</time>
{{ note.text | md | safe }}
{% if note.replies.length %}
<ul>
{% for r in note.replies %}
<li>{{ reply(r) }}</li>
{% endfor %}
</ul>
{% endif %}
</div>
{% endmacro %}

View File

@ -1,6 +1,7 @@
--- ---
layout: "base.njk" layout: "base.njk"
--- ---
{% import "components/reply.njk" as replyMacros %}
<main data-for="note"> <main data-for="note">
@ -11,23 +12,14 @@ layout: "base.njk"
<time class="dt-published" datetime="{{ note.createdAt | dateToRfc3339 }}">{{ note.createdAt | dateTimeDisplay }}</time> <time class="dt-published" datetime="{{ note.createdAt | dateToRfc3339 }}">{{ note.createdAt | dateTimeDisplay }}</time>
</div> </div>
{{ content | safe }} {{ content | safe }}
<pre>{{ note.replies | dump }}</pre>
<ul> <ul>
{% for reply in note.replies %}
<li>{{ reply.text | md | safe }}</li>
{% endfor %}
</ul>
{# <ul>
{% for reply in note.replies %} {% for reply in note.replies %}
<li> <li>
<div> {{ replyMacros.reply(reply) }}
<time class="dt-published" datetime="{{ reply.createdAt | dateToRfc3339 }}">{{ reply.createdAt | dateTimeDisplay }}</time>
{{ reply.text | md | safe }}
</div>
</li> </li>
{% endfor %} {% endfor %}
</ul> #} </ul>
</article> </article>
</main> </main>