Compare commits
No commits in common. "91fac7b4c75634235f19c427cbc0d053d0f28206" and "d0542271a07be0b6d324b7be49272e7eeae253e9" have entirely different histories.
91fac7b4c7
...
d0542271a0
@ -1,13 +1,10 @@
|
|||||||
const locale = 'en-GB'; // change this to your locale if you want a different date/time format
|
|
||||||
|
|
||||||
module.exports = function (eleventyConfig) {
|
module.exports = function (eleventyConfig) {
|
||||||
eleventyConfig.addFilter('dateDisplay', date => new Date(date).toLocaleDateString(locale, {
|
eleventyConfig.addFilter('dateDisplay', date => new Date(date).toLocaleDateString('en-GB', {
|
||||||
"dateStyle": "short"
|
"dateStyle": "short"
|
||||||
}));
|
}));
|
||||||
|
|
||||||
eleventyConfig.addFilter('dateTimeDisplay', date => new Date(date).toLocaleString(locale, {
|
eleventyConfig.addFilter('dateTimeDisplay', date => new Date(date).toLocaleString('en-GB', {
|
||||||
'dateStyle': 'short',
|
'dateStyle': 'short',
|
||||||
'timeStyle': 'short',
|
'timeStyle': 'short',
|
||||||
'hourCycle': 'h12'
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
@ -5,39 +5,18 @@ const formatMentions = text => {
|
|||||||
return text.replace(matcher, (match, username, domain) => {
|
return text.replace(matcher, (match, username, domain) => {
|
||||||
return `[${match}](https://${domain}/@${username})`;
|
return `[${match}](https://${domain}/@${username})`;
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
const extractAndFormatHashtags = note => {
|
|
||||||
const matcher = /#(\w+)/gm;
|
|
||||||
const hashtags = new Set();
|
|
||||||
note.text = note.text.replace(matcher, (match, hashtag) => {
|
|
||||||
hashtags.add(hashtag);
|
|
||||||
return `[${match}](/tags/${hashtag})`;
|
|
||||||
});
|
|
||||||
return Array.from(hashtags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = function() {
|
module.exports = function() {
|
||||||
const hashtags = {};
|
|
||||||
|
|
||||||
const notes = JSON.parse(fs.readFileSync('./src/_data/_notes.json', 'utf-8'))
|
const notes = JSON.parse(fs.readFileSync('./src/_data/_notes.json', 'utf-8'))
|
||||||
.filter(note => note.text !== null && note.visibility === "public")
|
.filter(note => note.text !== null && note.visibility === "public")
|
||||||
.map(note => {
|
.map(note => ({
|
||||||
extractAndFormatHashtags(note).forEach(hashtag => {
|
...note,
|
||||||
if (!hashtags[hashtag]) {
|
text: formatMentions(note.text),
|
||||||
hashtags[hashtag] = [];
|
createdAt: new Date(note.createdAt),
|
||||||
}
|
replies: []
|
||||||
hashtags[hashtag].push(note);
|
}));
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
...note,
|
|
||||||
text: formatMentions(note.text),
|
|
||||||
createdAt: new Date(note.createdAt),
|
|
||||||
replies: []
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
notes.forEach(note => {
|
notes.forEach(note => {
|
||||||
if (note.replyId) {
|
if (note.replyId) {
|
||||||
@ -45,11 +24,6 @@ module.exports = function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
console.log(JSON.stringify(notes.filter(note => note.replies.length && note.replies.find(reply => reply.replies.length)), null, 2));
|
||||||
notes,
|
return notes;
|
||||||
hashtags: Object.keys(hashtags).map(tag => ({
|
|
||||||
tag,
|
|
||||||
notes: hashtags[tag]
|
|
||||||
}))
|
|
||||||
};
|
|
||||||
}
|
}
|
@ -3,7 +3,6 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
|
|
||||||
<title>{{ title | safe }}</title>
|
|
||||||
<link rel="stylesheet" href="/styles/reset.css" />
|
<link rel="stylesheet" href="/styles/reset.css" />
|
||||||
<link rel="stylesheet" href="/styles/main.css" />
|
<link rel="stylesheet" href="/styles/main.css" />
|
||||||
</head>
|
</head>
|
||||||
|
@ -3,7 +3,7 @@ title: Firefish Archive
|
|||||||
---
|
---
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{% for note in notes.notes | topLevelNotes %}
|
{% for note in notes | topLevelNotes %}
|
||||||
<li>
|
<li>
|
||||||
<a href="/notes/{{ note.id }}">{{ note.id }} ({{ note | conversationLength }} replies)</a>
|
<a href="/notes/{{ note.id }}">{{ note.id }} ({{ note | conversationLength }} replies)</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
layout: "note.njk"
|
layout: "note.njk"
|
||||||
pagination:
|
pagination:
|
||||||
data: notes.notes
|
data: notes
|
||||||
size: 1
|
size: 1
|
||||||
alias: note
|
alias: note
|
||||||
eleventyComputed:
|
eleventyComputed:
|
||||||
|
@ -41,9 +41,6 @@ body {
|
|||||||
|
|
||||||
main {
|
main {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
max-width: var(--screen-lg);
|
|
||||||
margin: 0 auto;
|
|
||||||
padding: var(--space-size-m);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main[data-for="note"] {
|
main[data-for="note"] {
|
||||||
@ -54,20 +51,8 @@ main[data-for="note"] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
article {
|
article {
|
||||||
max-width: 80ch;
|
max-width: var(--screen-lg);
|
||||||
padding: var(--space-size-s);
|
padding: var(--space-size-s);
|
||||||
border: 1px solid #e2e8f0;
|
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
box-shadow: 0px 10px 15px -3px rgba(0,0,0,0.1);
|
box-shadow: 0px 10px 15px -3px rgba(0,0,0,0.1);
|
||||||
}
|
|
||||||
|
|
||||||
.p-author {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--space-size-3xs);
|
|
||||||
}
|
|
||||||
|
|
||||||
.p-author .p-name {
|
|
||||||
font-weight: bold;
|
|
||||||
font-size: var(--text-size-m);
|
|
||||||
}
|
}
|
25
src/tags.njk
25
src/tags.njk
@ -1,25 +0,0 @@
|
|||||||
---
|
|
||||||
layout: base.njk
|
|
||||||
pagination:
|
|
||||||
data: notes.hashtags
|
|
||||||
size: 1
|
|
||||||
alias: hashtag
|
|
||||||
eleventyComputed:
|
|
||||||
permalink: "/tags/{{ hashtag.tag }}/"
|
|
||||||
title: "#{{ hashtag.tag }}"
|
|
||||||
---
|
|
||||||
|
|
||||||
<main>
|
|
||||||
<h1>All notes for #{{ hashtag.tag }}</h1>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
{% for note in hashtag.notes %}
|
|
||||||
<li>
|
|
||||||
<div>
|
|
||||||
{{ note.text | md | safe }}
|
|
||||||
|
|
||||||
<a href="/notes/{{ note.id }}">Permalink</a>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
</main>
|
|
Loading…
Reference in New Issue
Block a user