21 lines
585 B
JavaScript
21 lines
585 B
JavaScript
const fs = require('node:fs');
|
|
|
|
const formatMentions = text => {
|
|
const matcher = /@(\w+)@([a-zA-Z\-_0-9\.]+)/gm;
|
|
return text.replace(matcher, (match, username, domain) => {
|
|
return `[${match}](https://${domain}/@${username})`;
|
|
});
|
|
|
|
}
|
|
|
|
module.exports = function() {
|
|
const notes = JSON.parse(fs.readFileSync('./src/_data/_notes.json', 'utf-8'))
|
|
.filter(note => note.text !== null)
|
|
.map(note => ({
|
|
...note,
|
|
text: formatMentions(note.text),
|
|
createdAt: new Date(note.createdAt)
|
|
}));
|
|
|
|
return notes;
|
|
} |