fix user pages

This commit is contained in:
biglyderv 2025-05-28 00:35:17 -04:00
parent cc33cde3e7
commit 38e9fd22a4
Signed by: biglyderv
GPG key ID: 0E2EB0B4CD7397B5
2 changed files with 8 additions and 4 deletions

10
lib.js
View file

@ -37,7 +37,11 @@ async function splitUp(content) {
let path = new URL(res.slice('file::'.length), 'https://tbg.dervland.net/').pathname;
if (ext == 'txt' || ext == 'json') {
let san = sanitize(path.split('/').pop(), '');
content = await readFile(`${process.cwd()}/uploads/${san}`, 'utf-8');
try {
content = await readFile(`${process.cwd()}/uploads/${san}`, 'utf-8');
} catch (err) {
content = '';
}
}
let contentJson = {};
@ -74,10 +78,10 @@ async function splitUp(content) {
continue;
}
if (res[0] == '#') {
out[i] = { type: 'link', name: res, href };
out[i] = { type: 'link', name: res, href };
continue;
}
out[i] = {type: 'normal', data: res};
out[i] = { type: 'normal', data: res };
}
return out;
}

View file

@ -23,6 +23,6 @@
</a>
<% } else if (contentN.type == 'link') { %>
<a class='link' href='<%= contentN.href %>'><%= contentN.name %></a>
<% } else if (contentN.data.replaceAll(' ','').length > 0) { %>
<% } else if (contentN.data && contentN.data.replaceAll(' ','').length > 0) { %>
<span class='commentbox'><%= contentN.data %></span>
<% } } %>