fix user pages
This commit is contained in:
parent
cc33cde3e7
commit
38e9fd22a4
2 changed files with 8 additions and 4 deletions
10
lib.js
10
lib.js
|
@ -37,7 +37,11 @@ async function splitUp(content) {
|
||||||
let path = new URL(res.slice('file::'.length), 'https://tbg.dervland.net/').pathname;
|
let path = new URL(res.slice('file::'.length), 'https://tbg.dervland.net/').pathname;
|
||||||
if (ext == 'txt' || ext == 'json') {
|
if (ext == 'txt' || ext == 'json') {
|
||||||
let san = sanitize(path.split('/').pop(), '');
|
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 = {};
|
let contentJson = {};
|
||||||
|
@ -74,10 +78,10 @@ async function splitUp(content) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (res[0] == '#') {
|
if (res[0] == '#') {
|
||||||
out[i] = { type: 'link', name: res, href };
|
out[i] = { type: 'link', name: res, href };
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
out[i] = {type: 'normal', data: res};
|
out[i] = { type: 'normal', data: res };
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,6 @@
|
||||||
</a>
|
</a>
|
||||||
<% } else if (contentN.type == 'link') { %>
|
<% } else if (contentN.type == 'link') { %>
|
||||||
<a class='link' href='<%= contentN.href %>'><%= contentN.name %></a>
|
<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>
|
<span class='commentbox'><%= contentN.data %></span>
|
||||||
<% } } %>
|
<% } } %>
|
Loading…
Add table
Add a link
Reference in a new issue