Skip to content

Commit e52146a

Browse files
committed
feat: placeholder html for attachments when they have not loaded yet
1 parent 11401f5 commit e52146a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

library.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ async function process(content, { type, pid, tid, attachments }) {
132132

133133
// Render cache hits immediately
134134
let attachmentHtml = '';
135+
let placeholderHtml = '';
135136
const cold = new Set();
136137
await Promise.all(Array.from(requests.keys()).map(async (url) => {
137138
const options = requests.get(url);
@@ -155,6 +156,9 @@ async function process(content, { type, pid, tid, attachments }) {
155156
}
156157
}
157158
} else {
159+
if (options.type === 'attachment') {
160+
placeholderHtml += `<p><a href="${url}" rel="nofollow ugc">${url}</a></p>`;
161+
}
158162
cold.add(url);
159163
}
160164
}));
@@ -217,6 +221,7 @@ async function process(content, { type, pid, tid, attachments }) {
217221

218222
content = $.html();
219223
content += attachmentHtml ? `\n\n<div class="row"><div class="col-12">${attachmentHtml}</div></div>` : '';
224+
content += placeholderHtml ? `\n\n<div class="row"><div class="col-12">${placeholderHtml}</div></div>` : '';
220225
return content;
221226
}
222227

0 commit comments

Comments
 (0)