@chrisburnell/eleventy-cache-webmentions 2.2.3 → 2.2.4
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"cachedAt":
|
|
1
|
+
{"cachedAt":1761780564178,"type":"json","metadata":{}}
|
|
@@ -13,9 +13,9 @@ const sanitizeHTML = require("sanitize-html");
|
|
|
13
13
|
* @property {string} uniqueKey
|
|
14
14
|
* @property {string} [cacheDirectory]
|
|
15
15
|
* @property {AllowedHTML} allowedHTML
|
|
16
|
-
* @property {string
|
|
17
|
-
* @property {string
|
|
18
|
-
* @property {{ string
|
|
16
|
+
* @property {Array<string>} allowlist
|
|
17
|
+
* @property {Array<string>} blocklist
|
|
18
|
+
* @property {{[key: string], string}} urlReplacements
|
|
19
19
|
* @property {number} maximumHtmlLength
|
|
20
20
|
* @property {string} maximumHtmlText
|
|
21
21
|
*/
|
|
@@ -117,7 +117,7 @@ const baseURL = (url) => {
|
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
119
|
* @param {string} url
|
|
120
|
-
* @param {{ string
|
|
120
|
+
* @param {{[key: string], string}} [urlReplacements]
|
|
121
121
|
* @returns {string}
|
|
122
122
|
*/
|
|
123
123
|
const fixURL = (url, urlReplacements) => {
|
|
@@ -151,8 +151,8 @@ const epoch = (date) => {
|
|
|
151
151
|
};
|
|
152
152
|
|
|
153
153
|
/**
|
|
154
|
-
* @param {Webmention
|
|
155
|
-
* @returns {Webmention
|
|
154
|
+
* @param {Array<Webmention>} webmentions
|
|
155
|
+
* @returns {Array<Webmention>}
|
|
156
156
|
*/
|
|
157
157
|
const removeDuplicates = (webmentions) => {
|
|
158
158
|
return [
|
|
@@ -259,9 +259,9 @@ const getType = (webmention) => {
|
|
|
259
259
|
};
|
|
260
260
|
|
|
261
261
|
/**
|
|
262
|
-
* @param {Webmention
|
|
263
|
-
* @param {WebmentionType|WebmentionType
|
|
264
|
-
* @returns {Webmention
|
|
262
|
+
* @param {Array<Webmention>} webmentions
|
|
263
|
+
* @param {WebmentionType|Array<WebmentionType>} types
|
|
264
|
+
* @returns {Array<Webmention>}
|
|
265
265
|
*/
|
|
266
266
|
const getByTypes = (webmentions, types) => {
|
|
267
267
|
return webmentions.filter((webmention) => {
|
|
@@ -273,9 +273,9 @@ const getByTypes = (webmentions, types) => {
|
|
|
273
273
|
};
|
|
274
274
|
|
|
275
275
|
/**
|
|
276
|
-
* @param {Webmention
|
|
277
|
-
* @param {string
|
|
278
|
-
* @returns {Webmention
|
|
276
|
+
* @param {Array<Webmention>} webmentions
|
|
277
|
+
* @param {Array<string>} blocklist
|
|
278
|
+
* @returns {Array<Webmention>}
|
|
279
279
|
*/
|
|
280
280
|
const processBlocklist = (webmentions, blocklist) => {
|
|
281
281
|
return webmentions.filter((webmention) => {
|
|
@@ -294,9 +294,9 @@ const processBlocklist = (webmentions, blocklist) => {
|
|
|
294
294
|
};
|
|
295
295
|
|
|
296
296
|
/**
|
|
297
|
-
* @param {Webmention
|
|
298
|
-
* @param {string
|
|
299
|
-
* @returns {Webmention
|
|
297
|
+
* @param {Array<Webmention>} webmentions
|
|
298
|
+
* @param {Array<string>} allowlist
|
|
299
|
+
* @returns {Array<Webmention>}
|
|
300
300
|
*/
|
|
301
301
|
const processAllowlist = (webmentions, allowlist) => {
|
|
302
302
|
return webmentions.filter((webmention) => {
|
|
@@ -316,9 +316,9 @@ const processAllowlist = (webmentions, allowlist) => {
|
|
|
316
316
|
|
|
317
317
|
/**
|
|
318
318
|
* @param {Options} options
|
|
319
|
-
* @param {Webmention
|
|
319
|
+
* @param {Array<Webmention>} webmentions
|
|
320
320
|
* @param {string} url
|
|
321
|
-
* @returns {Promise<{found: number, webmentions: Webmention
|
|
321
|
+
* @returns {Promise<{found: number, webmentions: Array<Webmention>}>}
|
|
322
322
|
*/
|
|
323
323
|
const fetchWebmentions = async (options, webmentions, url) => {
|
|
324
324
|
return await fetch(url)
|
|
@@ -384,7 +384,7 @@ const fetchWebmentions = async (options, webmentions, url) => {
|
|
|
384
384
|
|
|
385
385
|
/**
|
|
386
386
|
* @param {Options} options
|
|
387
|
-
* @returns {Promise<Webmention
|
|
387
|
+
* @returns {Promise<Array<Webmention>>}
|
|
388
388
|
*/
|
|
389
389
|
const retrieveWebmentions = async (options) => {
|
|
390
390
|
if (!options.domain) {
|
|
@@ -516,12 +516,12 @@ const retrieveWebmentions = async (options) => {
|
|
|
516
516
|
return webmentions;
|
|
517
517
|
};
|
|
518
518
|
|
|
519
|
-
/** @type {Webmention
|
|
519
|
+
/** @type {Array<Webmention>} */
|
|
520
520
|
const WEBMENTIONS = {};
|
|
521
521
|
|
|
522
522
|
/**
|
|
523
523
|
* @param {Options} options
|
|
524
|
-
* @returns {Promise<{ string
|
|
524
|
+
* @returns {Promise<{[key: string], Array<Webmention>}>}
|
|
525
525
|
*/
|
|
526
526
|
const webmentionsByURL = async (options) => {
|
|
527
527
|
if (Object.keys(WEBMENTIONS).length) {
|
|
@@ -553,8 +553,8 @@ const webmentionsByURL = async (options) => {
|
|
|
553
553
|
/**
|
|
554
554
|
* @param {Options} options
|
|
555
555
|
* @param {string} url
|
|
556
|
-
* @param {WebmentionType
|
|
557
|
-
* @returns {Promise<Webmention
|
|
556
|
+
* @param {WebmentionType|Array<WebmentionType>} [types]
|
|
557
|
+
* @returns {Promise<Array<Webmention>>}
|
|
558
558
|
*/
|
|
559
559
|
const getWebmentions = async (options, url, types = []) => {
|
|
560
560
|
const webmentions = await webmentionsByURL(options);
|
|
@@ -603,7 +603,7 @@ const getWebmentions = async (options, url, types = []) => {
|
|
|
603
603
|
|
|
604
604
|
/**
|
|
605
605
|
* @param {object} eleventyConfig
|
|
606
|
-
* @param {Options} [options
|
|
606
|
+
* @param {Options} [options]
|
|
607
607
|
*/
|
|
608
608
|
const eleventyCacheWebmentions = async (eleventyConfig, options = {}) => {
|
|
609
609
|
options = Object.assign(defaults, options);
|
|
@@ -13,9 +13,9 @@ import sanitizeHTML from "sanitize-html";
|
|
|
13
13
|
* @property {string} uniqueKey
|
|
14
14
|
* @property {string} [cacheDirectory]
|
|
15
15
|
* @property {AllowedHTML} allowedHTML
|
|
16
|
-
* @property {string
|
|
17
|
-
* @property {string
|
|
18
|
-
* @property {{ string
|
|
16
|
+
* @property {Array<string>} allowlist
|
|
17
|
+
* @property {Array<string>} blocklist
|
|
18
|
+
* @property {{[key: string], string}} urlReplacements
|
|
19
19
|
* @property {number} maximumHtmlLength
|
|
20
20
|
* @property {string} maximumHtmlText
|
|
21
21
|
*/
|
|
@@ -117,7 +117,7 @@ const baseURL = (url) => {
|
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
119
|
* @param {string} url
|
|
120
|
-
* @param {{ string
|
|
120
|
+
* @param {{[key: string], string}} [urlReplacements]
|
|
121
121
|
* @returns {string}
|
|
122
122
|
*/
|
|
123
123
|
const fixURL = (url, urlReplacements) => {
|
|
@@ -151,8 +151,8 @@ const epoch = (date) => {
|
|
|
151
151
|
};
|
|
152
152
|
|
|
153
153
|
/**
|
|
154
|
-
* @param {Webmention
|
|
155
|
-
* @returns {Webmention
|
|
154
|
+
* @param {Array<Webmention>} webmentions
|
|
155
|
+
* @returns {Array<Webmention>}
|
|
156
156
|
*/
|
|
157
157
|
const removeDuplicates = (webmentions) => {
|
|
158
158
|
return [
|
|
@@ -266,9 +266,9 @@ export const getType = (webmention) => {
|
|
|
266
266
|
export const getWebmentionType = getType;
|
|
267
267
|
|
|
268
268
|
/**
|
|
269
|
-
* @param {Webmention
|
|
270
|
-
* @param {WebmentionType|WebmentionType
|
|
271
|
-
* @returns {Webmention
|
|
269
|
+
* @param {Array<Webmention>} webmentions
|
|
270
|
+
* @param {WebmentionType|Array<WebmentionType>} types
|
|
271
|
+
* @returns {Array<Webmention>}
|
|
272
272
|
*/
|
|
273
273
|
export const getByTypes = (webmentions, types) => {
|
|
274
274
|
return webmentions.filter((webmention) => {
|
|
@@ -283,9 +283,9 @@ export const getWebmentionsByTypes = getByTypes;
|
|
|
283
283
|
export const getWebmentionsByType = getByTypes;
|
|
284
284
|
|
|
285
285
|
/**
|
|
286
|
-
* @param {Webmention
|
|
287
|
-
* @param {string
|
|
288
|
-
* @returns {Webmention
|
|
286
|
+
* @param {Array<Webmention>} webmentions
|
|
287
|
+
* @param {Array<string>} blocklist
|
|
288
|
+
* @returns {Array<Webmention>}
|
|
289
289
|
*/
|
|
290
290
|
export const processBlocklist = (webmentions, blocklist) => {
|
|
291
291
|
return webmentions.filter((webmention) => {
|
|
@@ -306,9 +306,9 @@ export const processWebmentionBlocklist = processBlocklist;
|
|
|
306
306
|
export const processWebmentionsBlocklist = processBlocklist;
|
|
307
307
|
|
|
308
308
|
/**
|
|
309
|
-
* @param {Webmention
|
|
310
|
-
* @param {string
|
|
311
|
-
* @returns {Webmention
|
|
309
|
+
* @param {Array<Webmention>} webmentions
|
|
310
|
+
* @param {Array<string>} allowlist
|
|
311
|
+
* @returns {Array<Webmention>}
|
|
312
312
|
*/
|
|
313
313
|
export const processAllowlist = (webmentions, allowlist) => {
|
|
314
314
|
return webmentions.filter((webmention) => {
|
|
@@ -330,9 +330,9 @@ export const processWebmentionsAllowlist = processAllowlist;
|
|
|
330
330
|
|
|
331
331
|
/**
|
|
332
332
|
* @param {Options} options
|
|
333
|
-
* @param {Webmention
|
|
333
|
+
* @param {Array<Webmention>} webmentions
|
|
334
334
|
* @param {string} url
|
|
335
|
-
* @returns {Promise<{found: number, webmentions: Webmention
|
|
335
|
+
* @returns {Promise<{found: number, webmentions: Array<Webmention>}>}
|
|
336
336
|
*/
|
|
337
337
|
export const fetchWebmentions = async (options, webmentions, url) => {
|
|
338
338
|
return await fetch(url)
|
|
@@ -398,7 +398,7 @@ export const fetchWebmentions = async (options, webmentions, url) => {
|
|
|
398
398
|
|
|
399
399
|
/**
|
|
400
400
|
* @param {Options} options
|
|
401
|
-
* @returns {Promise<Webmention
|
|
401
|
+
* @returns {Promise<Array<Webmention>>}
|
|
402
402
|
*/
|
|
403
403
|
export const retrieveWebmentions = async (options) => {
|
|
404
404
|
if (!options.domain) {
|
|
@@ -530,12 +530,12 @@ export const retrieveWebmentions = async (options) => {
|
|
|
530
530
|
return webmentions;
|
|
531
531
|
};
|
|
532
532
|
|
|
533
|
-
/** @type {Webmention
|
|
533
|
+
/** @type {Array<Webmention>} */
|
|
534
534
|
const WEBMENTIONS = {};
|
|
535
535
|
|
|
536
536
|
/**
|
|
537
537
|
* @param {Options} options
|
|
538
|
-
* @returns {Promise<{ string
|
|
538
|
+
* @returns {Promise<{[key: string], Array<Webmention>}>}
|
|
539
539
|
*/
|
|
540
540
|
export const webmentionsByURL = async (options) => {
|
|
541
541
|
if (Object.keys(WEBMENTIONS).length) {
|
|
@@ -569,8 +569,8 @@ export const filteredWebmentions = webmentionsByURL;
|
|
|
569
569
|
/**
|
|
570
570
|
* @param {Options} options
|
|
571
571
|
* @param {string} url
|
|
572
|
-
* @param {WebmentionType
|
|
573
|
-
* @returns {Promise<Webmention
|
|
572
|
+
* @param {WebmentionType|Array<WebmentionType>} [types]
|
|
573
|
+
* @returns {Promise<Array<Webmention>>}
|
|
574
574
|
*/
|
|
575
575
|
export const getWebmentions = async (options, url, types = []) => {
|
|
576
576
|
const webmentions = await webmentionsByURL(options);
|
|
@@ -619,7 +619,7 @@ export const getWebmentions = async (options, url, types = []) => {
|
|
|
619
619
|
|
|
620
620
|
/**
|
|
621
621
|
* @param {object} eleventyConfig
|
|
622
|
-
* @param {Options} [options
|
|
622
|
+
* @param {Options} [options]
|
|
623
623
|
*/
|
|
624
624
|
export const eleventyCacheWebmentions = async (
|
|
625
625
|
eleventyConfig,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chrisburnell/eleventy-cache-webmentions",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4",
|
|
4
4
|
"description": "Cache webmentions using eleventy-fetch and make them available to use in collections, layouts, pages, etc. in Eleventy.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|