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) {
 | 
			
		||||
    eleventyConfig.addFilter('dateDisplay', date => new Date(date).toLocaleDateString(locale, {
 | 
			
		||||
    eleventyConfig.addFilter('dateDisplay', date => new Date(date).toLocaleDateString('en-GB', {
 | 
			
		||||
        "dateStyle": "short"
 | 
			
		||||
      }));
 | 
			
		||||
    
 | 
			
		||||
      eleventyConfig.addFilter('dateTimeDisplay', date => new Date(date).toLocaleString(locale, {
 | 
			
		||||
      eleventyConfig.addFilter('dateTimeDisplay', date => new Date(date).toLocaleString('en-GB', {
 | 
			
		||||
        'dateStyle': 'short',
 | 
			
		||||
        'timeStyle': 'short',
 | 
			
		||||
        'hourCycle': 'h12'
 | 
			
		||||
      }));    
 | 
			
		||||
}
 | 
			
		||||
@ -5,39 +5,18 @@ const formatMentions = text => {
 | 
			
		||||
    return text.replace(matcher, (match, username, domain) => {
 | 
			
		||||
        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() {
 | 
			
		||||
    const hashtags = {};
 | 
			
		||||
 | 
			
		||||
    const notes = JSON.parse(fs.readFileSync('./src/_data/_notes.json', 'utf-8'))
 | 
			
		||||
        .filter(note => note.text !== null && note.visibility === "public")
 | 
			
		||||
        .map(note => {
 | 
			
		||||
            extractAndFormatHashtags(note).forEach(hashtag => {
 | 
			
		||||
                if (!hashtags[hashtag]) {
 | 
			
		||||
                    hashtags[hashtag] = [];
 | 
			
		||||
                }
 | 
			
		||||
                hashtags[hashtag].push(note);
 | 
			
		||||
            });
 | 
			
		||||
    
 | 
			
		||||
            return {
 | 
			
		||||
                ...note,
 | 
			
		||||
                text: formatMentions(note.text),
 | 
			
		||||
                createdAt: new Date(note.createdAt),
 | 
			
		||||
                replies: []
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        .map(note => ({
 | 
			
		||||
            ...note,
 | 
			
		||||
            text: formatMentions(note.text),
 | 
			
		||||
            createdAt: new Date(note.createdAt),
 | 
			
		||||
            replies: []
 | 
			
		||||
        }));
 | 
			
		||||
    
 | 
			
		||||
    notes.forEach(note => {
 | 
			
		||||
        if (note.replyId) {
 | 
			
		||||
@ -45,11 +24,6 @@ module.exports = function() {
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
    
 | 
			
		||||
    return {
 | 
			
		||||
        notes,
 | 
			
		||||
        hashtags: Object.keys(hashtags).map(tag => ({
 | 
			
		||||
            tag,
 | 
			
		||||
            notes: hashtags[tag]
 | 
			
		||||
        }))
 | 
			
		||||
    };
 | 
			
		||||
    console.log(JSON.stringify(notes.filter(note => note.replies.length && note.replies.find(reply => reply.replies.length)), null, 2));
 | 
			
		||||
    return notes;
 | 
			
		||||
}
 | 
			
		||||
@ -3,7 +3,6 @@
 | 
			
		||||
<head>
 | 
			
		||||
    <meta charset="utf-8" />
 | 
			
		||||
 | 
			
		||||
    <title>{{ title | safe }}</title>
 | 
			
		||||
    <link rel="stylesheet" href="/styles/reset.css" />
 | 
			
		||||
    <link rel="stylesheet" href="/styles/main.css" />
 | 
			
		||||
</head>
 | 
			
		||||
 | 
			
		||||
@ -3,7 +3,7 @@ title: Firefish Archive
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
<ul>
 | 
			
		||||
    {% for note in notes.notes | topLevelNotes %}
 | 
			
		||||
    {% for note in notes | topLevelNotes %}
 | 
			
		||||
        <li>
 | 
			
		||||
            <a href="/notes/{{ note.id }}">{{ note.id }} ({{ note | conversationLength }} replies)</a>
 | 
			
		||||
        </li>
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
---
 | 
			
		||||
layout: "note.njk"
 | 
			
		||||
pagination:
 | 
			
		||||
    data: notes.notes
 | 
			
		||||
    data: notes
 | 
			
		||||
    size: 1
 | 
			
		||||
    alias: note
 | 
			
		||||
eleventyComputed:
 | 
			
		||||
 | 
			
		||||
@ -41,9 +41,6 @@ body {
 | 
			
		||||
 | 
			
		||||
main {
 | 
			
		||||
    height: 100%;
 | 
			
		||||
    max-width: var(--screen-lg);
 | 
			
		||||
    margin: 0 auto;
 | 
			
		||||
    padding: var(--space-size-m);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
main[data-for="note"] {
 | 
			
		||||
@ -54,20 +51,8 @@ main[data-for="note"] {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
article {
 | 
			
		||||
    max-width: 80ch;
 | 
			
		||||
    max-width: var(--screen-lg);
 | 
			
		||||
    padding: var(--space-size-s);
 | 
			
		||||
    border: 1px solid #e2e8f0;
 | 
			
		||||
    border-radius: 5px;
 | 
			
		||||
    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