This commit is contained in:
Lewis Dale 2024-01-21 11:07:03 +00:00
parent c0d24cf08a
commit a7d6b76eb3
6 changed files with 18 additions and 7 deletions

View File

@ -4,7 +4,7 @@
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "serve": "npx @11ty/eleventy --serve"
}, },
"author": "", "author": "",
"license": "ISC", "license": "ISC",

View File

@ -3,7 +3,7 @@ const fs = require('node:fs');
const formatMentions = text => { const formatMentions = text => {
const matcher = /@(\w+)@([a-zA-Z\-_0-9\.]+)/gm; const matcher = /@(\w+)@([a-zA-Z\-_0-9\.]+)/gm;
return text.replace(matcher, (match, username, domain) => { return text.replace(matcher, (match, username, domain) => {
return `[${match}](https://${domain}/@${username})`; return `<a href="https://${domain}/@${username}" class="u-in-reply-to">${match}</a>`;
}); });
} }

View File

@ -1,13 +1,15 @@
{% macro reply(note) %} {% macro reply(note) %}
<div> <div class="h-entry">
<a href="/notes/{{ note.replyId }}" class="u-in-reply-to"></a>
<time class="dt-published" datetime="{{ note.createdAt | dateToRfc3339 }}">{{ note.createdAt | dateTimeDisplay }}</time> <time class="dt-published" datetime="{{ note.createdAt | dateToRfc3339 }}">{{ note.createdAt | dateTimeDisplay }}</time>
{{ note.text | md | safe }} {{ note.text | md | safe }}
{% if note.replies.length %} {% if note.replies.length %}
<ul> <ul class="h-feed">
{% for r in note.replies %} {% for r in note.replies %}
<li>{{ reply(r) }}</li> <li>{{ reply(r) }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %}
<a href="/notes/{{ note.id }}" class="u-url">permalink</a>
</div> </div>
{% endmacro %} {% endmacro %}

View File

@ -13,6 +13,8 @@ layout: "base.njk"
</div> </div>
{{ content | safe }} {{ content | safe }}
{% if note.files | length %}
<details> <details>
<summary>Media</summary> <summary>Media</summary>
<ul class="grid"> <ul class="grid">
@ -22,8 +24,9 @@ layout: "base.njk"
</li> </li>
{% endfor %} {% endfor %}
</details> </details>
{% endif %}
<ul> <ul class="h-feed">
{% for reply in note.replies %} {% for reply in note.replies %}
<li> <li>
{{ replyMacros.reply(reply) }} {{ replyMacros.reply(reply) }}

View File

@ -8,4 +8,4 @@ eleventyComputed:
permalink: "/notes/{{ note.id }}" permalink: "/notes/{{ note.id }}"
--- ---
{{ note.text }} {{ note.text | safe}}

View File

@ -70,6 +70,11 @@ ul.h-feed > li {
margin-bottom: var(--space-size-m); margin-bottom: var(--space-size-m);
} }
.h-entry .h-feed {
padding-left: var(--space-size-s);
border-left: 3px solid rgba(0,0,0,0.1);
}
.p-author { .p-author {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -90,4 +95,5 @@ ul.h-feed > li {
ul.grid { ul.grid {
list-style: none; list-style: none;
padding: 0; padding: 0;
} }