nodebb-plugin-link-preview 2.0.8 → 2.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/library.js +6 -1
- package/package-lock.json +4889 -0
- package/package.json +1 -1
package/library.js
CHANGED
|
@@ -132,6 +132,7 @@ async function process(content, { type, pid, tid, attachments }) {
|
|
|
132
132
|
|
|
133
133
|
// Render cache hits immediately
|
|
134
134
|
let attachmentHtml = '';
|
|
135
|
+
let placeholderHtml = '';
|
|
135
136
|
const cold = new Set();
|
|
136
137
|
await Promise.all(Array.from(requests.keys()).map(async (url) => {
|
|
137
138
|
const options = requests.get(url);
|
|
@@ -155,6 +156,9 @@ async function process(content, { type, pid, tid, attachments }) {
|
|
|
155
156
|
}
|
|
156
157
|
}
|
|
157
158
|
} else {
|
|
159
|
+
if (options.type === 'attachment') {
|
|
160
|
+
placeholderHtml += `<p><a href="${url}" rel="nofollow ugc">${url}</a></p>`;
|
|
161
|
+
}
|
|
158
162
|
cold.add(url);
|
|
159
163
|
}
|
|
160
164
|
}));
|
|
@@ -217,6 +221,7 @@ async function process(content, { type, pid, tid, attachments }) {
|
|
|
217
221
|
|
|
218
222
|
content = $.html();
|
|
219
223
|
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>` : '';
|
|
220
225
|
return content;
|
|
221
226
|
}
|
|
222
227
|
|
|
@@ -296,7 +301,7 @@ plugin.onParse = async (payload) => {
|
|
|
296
301
|
if (typeof payload === 'string') { // raw
|
|
297
302
|
const type = 'default';
|
|
298
303
|
payload = await process(payload, { type });
|
|
299
|
-
} else if (payload && payload.postData && payload.postData.content) { // post
|
|
304
|
+
} else if (payload && payload.type !== 'plaintext' && payload.postData && payload.postData.content) { // post
|
|
300
305
|
const { content, pid, tid, attachments } = payload.postData;
|
|
301
306
|
const { type } = payload;
|
|
302
307
|
payload.postData.content = await process(content, { type, pid, tid, attachments });
|