@chrisburnell/eleventy-cache-webmentions 2.2.3 → 2.2.7
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":1764872868125,"type":"json","metadata":{}}
|
|
@@ -13,12 +13,29 @@ 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: 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
|
*/
|
|
22
|
+
const defaults = {
|
|
23
|
+
refresh: false,
|
|
24
|
+
duration: "1d",
|
|
25
|
+
uniqueKey: "webmentions",
|
|
26
|
+
cacheDirectory: undefined,
|
|
27
|
+
allowedHTML: {
|
|
28
|
+
allowedTags: ["a", "b", "em", "i", "strong"],
|
|
29
|
+
allowedAttributes: {
|
|
30
|
+
a: ["href"],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
allowlist: [],
|
|
34
|
+
blocklist: [],
|
|
35
|
+
urlReplacements: {},
|
|
36
|
+
maximumHtmlLength: 1000,
|
|
37
|
+
maximumHtmlText: "mentioned this in",
|
|
38
|
+
};
|
|
22
39
|
|
|
23
40
|
/**
|
|
24
41
|
* @typedef {object} OptionsUserInput
|
|
@@ -61,27 +78,6 @@ const sanitizeHTML = require("sanitize-html");
|
|
|
61
78
|
* @typedef {"bookmark-of"|"like-of"|"repost-of"|"mention-of"|"in-reply-to"} WebmentionType
|
|
62
79
|
*/
|
|
63
80
|
|
|
64
|
-
/**
|
|
65
|
-
* @type {OptionsDefaults}
|
|
66
|
-
*/
|
|
67
|
-
const defaults = {
|
|
68
|
-
refresh: false,
|
|
69
|
-
duration: "1d",
|
|
70
|
-
uniqueKey: "webmentions",
|
|
71
|
-
cacheDirectory: undefined,
|
|
72
|
-
allowedHTML: {
|
|
73
|
-
allowedTags: ["a", "b", "em", "i", "strong"],
|
|
74
|
-
allowedAttributes: {
|
|
75
|
-
a: ["href"],
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
allowlist: [],
|
|
79
|
-
blocklist: [],
|
|
80
|
-
urlReplacements: {},
|
|
81
|
-
maximumHtmlLength: 1000,
|
|
82
|
-
maximumHtmlText: "mentioned this in",
|
|
83
|
-
};
|
|
84
|
-
|
|
85
81
|
/**
|
|
86
82
|
* @param {string} url
|
|
87
83
|
* @param {string} domain
|
|
@@ -117,7 +113,7 @@ const baseURL = (url) => {
|
|
|
117
113
|
|
|
118
114
|
/**
|
|
119
115
|
* @param {string} url
|
|
120
|
-
* @param {{ string
|
|
116
|
+
* @param {{[key: string], string}} [urlReplacements]
|
|
121
117
|
* @returns {string}
|
|
122
118
|
*/
|
|
123
119
|
const fixURL = (url, urlReplacements) => {
|
|
@@ -151,8 +147,8 @@ const epoch = (date) => {
|
|
|
151
147
|
};
|
|
152
148
|
|
|
153
149
|
/**
|
|
154
|
-
* @param {Webmention
|
|
155
|
-
* @returns {Webmention
|
|
150
|
+
* @param {Array<Webmention>} webmentions
|
|
151
|
+
* @returns {Array<Webmention>}
|
|
156
152
|
*/
|
|
157
153
|
const removeDuplicates = (webmentions) => {
|
|
158
154
|
return [
|
|
@@ -259,9 +255,9 @@ const getType = (webmention) => {
|
|
|
259
255
|
};
|
|
260
256
|
|
|
261
257
|
/**
|
|
262
|
-
* @param {Webmention
|
|
263
|
-
* @param {WebmentionType|WebmentionType
|
|
264
|
-
* @returns {Webmention
|
|
258
|
+
* @param {Array<Webmention>} webmentions
|
|
259
|
+
* @param {WebmentionType|Array<WebmentionType>} types
|
|
260
|
+
* @returns {Array<Webmention>}
|
|
265
261
|
*/
|
|
266
262
|
const getByTypes = (webmentions, types) => {
|
|
267
263
|
return webmentions.filter((webmention) => {
|
|
@@ -273,9 +269,9 @@ const getByTypes = (webmentions, types) => {
|
|
|
273
269
|
};
|
|
274
270
|
|
|
275
271
|
/**
|
|
276
|
-
* @param {Webmention
|
|
277
|
-
* @param {string
|
|
278
|
-
* @returns {Webmention
|
|
272
|
+
* @param {Array<Webmention>} webmentions
|
|
273
|
+
* @param {Array<string>} blocklist
|
|
274
|
+
* @returns {Array<Webmention>}
|
|
279
275
|
*/
|
|
280
276
|
const processBlocklist = (webmentions, blocklist) => {
|
|
281
277
|
return webmentions.filter((webmention) => {
|
|
@@ -294,9 +290,9 @@ const processBlocklist = (webmentions, blocklist) => {
|
|
|
294
290
|
};
|
|
295
291
|
|
|
296
292
|
/**
|
|
297
|
-
* @param {Webmention
|
|
298
|
-
* @param {string
|
|
299
|
-
* @returns {Webmention
|
|
293
|
+
* @param {Array<Webmention>} webmentions
|
|
294
|
+
* @param {Array<string>} allowlist
|
|
295
|
+
* @returns {Array<Webmention>}
|
|
300
296
|
*/
|
|
301
297
|
const processAllowlist = (webmentions, allowlist) => {
|
|
302
298
|
return webmentions.filter((webmention) => {
|
|
@@ -316,9 +312,9 @@ const processAllowlist = (webmentions, allowlist) => {
|
|
|
316
312
|
|
|
317
313
|
/**
|
|
318
314
|
* @param {Options} options
|
|
319
|
-
* @param {Webmention
|
|
315
|
+
* @param {Array<Webmention>} webmentions
|
|
320
316
|
* @param {string} url
|
|
321
|
-
* @returns {Promise<{found: number, webmentions: Webmention
|
|
317
|
+
* @returns {Promise<{found: number, webmentions: Array<Webmention>}>}
|
|
322
318
|
*/
|
|
323
319
|
const fetchWebmentions = async (options, webmentions, url) => {
|
|
324
320
|
return await fetch(url)
|
|
@@ -384,7 +380,7 @@ const fetchWebmentions = async (options, webmentions, url) => {
|
|
|
384
380
|
|
|
385
381
|
/**
|
|
386
382
|
* @param {Options} options
|
|
387
|
-
* @returns {Promise<Webmention
|
|
383
|
+
* @returns {Promise<Array<Webmention>>}
|
|
388
384
|
*/
|
|
389
385
|
const retrieveWebmentions = async (options) => {
|
|
390
386
|
if (!options.domain) {
|
|
@@ -516,12 +512,12 @@ const retrieveWebmentions = async (options) => {
|
|
|
516
512
|
return webmentions;
|
|
517
513
|
};
|
|
518
514
|
|
|
519
|
-
/** @type {Webmention
|
|
515
|
+
/** @type {Array<Webmention>} */
|
|
520
516
|
const WEBMENTIONS = {};
|
|
521
517
|
|
|
522
518
|
/**
|
|
523
519
|
* @param {Options} options
|
|
524
|
-
* @returns {Promise<{ string: Webmention
|
|
520
|
+
* @returns {Promise<{[key: string]: Array<Webmention>}>}
|
|
525
521
|
*/
|
|
526
522
|
const webmentionsByURL = async (options) => {
|
|
527
523
|
if (Object.keys(WEBMENTIONS).length) {
|
|
@@ -553,8 +549,8 @@ const webmentionsByURL = async (options) => {
|
|
|
553
549
|
/**
|
|
554
550
|
* @param {Options} options
|
|
555
551
|
* @param {string} url
|
|
556
|
-
* @param {WebmentionType
|
|
557
|
-
* @returns {Promise<Webmention
|
|
552
|
+
* @param {WebmentionType|Array<WebmentionType>} [types]
|
|
553
|
+
* @returns {Promise<Array<Webmention>>}
|
|
558
554
|
*/
|
|
559
555
|
const getWebmentions = async (options, url, types = []) => {
|
|
560
556
|
const webmentions = await webmentionsByURL(options);
|
|
@@ -603,7 +599,7 @@ const getWebmentions = async (options, url, types = []) => {
|
|
|
603
599
|
|
|
604
600
|
/**
|
|
605
601
|
* @param {object} eleventyConfig
|
|
606
|
-
* @param {Options} [options
|
|
602
|
+
* @param {Options} [options]
|
|
607
603
|
*/
|
|
608
604
|
const eleventyCacheWebmentions = async (eleventyConfig, options = {}) => {
|
|
609
605
|
options = Object.assign(defaults, options);
|
|
@@ -13,12 +13,29 @@ 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: 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
|
*/
|
|
22
|
+
export const defaults = {
|
|
23
|
+
refresh: false,
|
|
24
|
+
duration: "1d",
|
|
25
|
+
uniqueKey: "webmentions",
|
|
26
|
+
cacheDirectory: undefined,
|
|
27
|
+
allowedHTML: {
|
|
28
|
+
allowedTags: ["a", "b", "em", "i", "strong"],
|
|
29
|
+
allowedAttributes: {
|
|
30
|
+
a: ["href"],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
allowlist: [],
|
|
34
|
+
blocklist: [],
|
|
35
|
+
urlReplacements: {},
|
|
36
|
+
maximumHtmlLength: 1000,
|
|
37
|
+
maximumHtmlText: "mentioned this in",
|
|
38
|
+
};
|
|
22
39
|
|
|
23
40
|
/**
|
|
24
41
|
* @typedef {object} OptionsUserInput
|
|
@@ -61,27 +78,6 @@ import sanitizeHTML from "sanitize-html";
|
|
|
61
78
|
* @typedef {"bookmark-of"|"like-of"|"repost-of"|"mention-of"|"in-reply-to"} WebmentionType
|
|
62
79
|
*/
|
|
63
80
|
|
|
64
|
-
/**
|
|
65
|
-
* @type {OptionsDefaults}
|
|
66
|
-
*/
|
|
67
|
-
export const defaults = {
|
|
68
|
-
refresh: false,
|
|
69
|
-
duration: "1d",
|
|
70
|
-
uniqueKey: "webmentions",
|
|
71
|
-
cacheDirectory: undefined,
|
|
72
|
-
allowedHTML: {
|
|
73
|
-
allowedTags: ["a", "b", "em", "i", "strong"],
|
|
74
|
-
allowedAttributes: {
|
|
75
|
-
a: ["href"],
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
allowlist: [],
|
|
79
|
-
blocklist: [],
|
|
80
|
-
urlReplacements: {},
|
|
81
|
-
maximumHtmlLength: 1000,
|
|
82
|
-
maximumHtmlText: "mentioned this in",
|
|
83
|
-
};
|
|
84
|
-
|
|
85
81
|
/**
|
|
86
82
|
* @param {string} url
|
|
87
83
|
* @param {string} domain
|
|
@@ -117,7 +113,7 @@ const baseURL = (url) => {
|
|
|
117
113
|
|
|
118
114
|
/**
|
|
119
115
|
* @param {string} url
|
|
120
|
-
* @param {{ string: string
|
|
116
|
+
* @param {{[key: string]: string}} [urlReplacements]
|
|
121
117
|
* @returns {string}
|
|
122
118
|
*/
|
|
123
119
|
const fixURL = (url, urlReplacements) => {
|
|
@@ -151,8 +147,8 @@ const epoch = (date) => {
|
|
|
151
147
|
};
|
|
152
148
|
|
|
153
149
|
/**
|
|
154
|
-
* @param {Webmention
|
|
155
|
-
* @returns {Webmention
|
|
150
|
+
* @param {Array<Webmention>} webmentions
|
|
151
|
+
* @returns {Array<Webmention>}
|
|
156
152
|
*/
|
|
157
153
|
const removeDuplicates = (webmentions) => {
|
|
158
154
|
return [
|
|
@@ -266,9 +262,9 @@ export const getType = (webmention) => {
|
|
|
266
262
|
export const getWebmentionType = getType;
|
|
267
263
|
|
|
268
264
|
/**
|
|
269
|
-
* @param {Webmention
|
|
270
|
-
* @param {WebmentionType|WebmentionType
|
|
271
|
-
* @returns {Webmention
|
|
265
|
+
* @param {Array<Webmention>} webmentions
|
|
266
|
+
* @param {WebmentionType|Array<WebmentionType>} types
|
|
267
|
+
* @returns {Array<Webmention>}
|
|
272
268
|
*/
|
|
273
269
|
export const getByTypes = (webmentions, types) => {
|
|
274
270
|
return webmentions.filter((webmention) => {
|
|
@@ -283,9 +279,9 @@ export const getWebmentionsByTypes = getByTypes;
|
|
|
283
279
|
export const getWebmentionsByType = getByTypes;
|
|
284
280
|
|
|
285
281
|
/**
|
|
286
|
-
* @param {Webmention
|
|
287
|
-
* @param {string
|
|
288
|
-
* @returns {Webmention
|
|
282
|
+
* @param {Array<Webmention>} webmentions
|
|
283
|
+
* @param {Array<string>} blocklist
|
|
284
|
+
* @returns {Array<Webmention>}
|
|
289
285
|
*/
|
|
290
286
|
export const processBlocklist = (webmentions, blocklist) => {
|
|
291
287
|
return webmentions.filter((webmention) => {
|
|
@@ -306,9 +302,9 @@ export const processWebmentionBlocklist = processBlocklist;
|
|
|
306
302
|
export const processWebmentionsBlocklist = processBlocklist;
|
|
307
303
|
|
|
308
304
|
/**
|
|
309
|
-
* @param {Webmention
|
|
310
|
-
* @param {string
|
|
311
|
-
* @returns {Webmention
|
|
305
|
+
* @param {Array<Webmention>} webmentions
|
|
306
|
+
* @param {Array<string>} allowlist
|
|
307
|
+
* @returns {Array<Webmention>}
|
|
312
308
|
*/
|
|
313
309
|
export const processAllowlist = (webmentions, allowlist) => {
|
|
314
310
|
return webmentions.filter((webmention) => {
|
|
@@ -330,9 +326,9 @@ export const processWebmentionsAllowlist = processAllowlist;
|
|
|
330
326
|
|
|
331
327
|
/**
|
|
332
328
|
* @param {Options} options
|
|
333
|
-
* @param {Webmention
|
|
329
|
+
* @param {Array<Webmention>} webmentions
|
|
334
330
|
* @param {string} url
|
|
335
|
-
* @returns {Promise<{found: number, webmentions: Webmention
|
|
331
|
+
* @returns {Promise<{found: number, webmentions: Array<Webmention>}>}
|
|
336
332
|
*/
|
|
337
333
|
export const fetchWebmentions = async (options, webmentions, url) => {
|
|
338
334
|
return await fetch(url)
|
|
@@ -398,7 +394,7 @@ export const fetchWebmentions = async (options, webmentions, url) => {
|
|
|
398
394
|
|
|
399
395
|
/**
|
|
400
396
|
* @param {Options} options
|
|
401
|
-
* @returns {Promise<Webmention
|
|
397
|
+
* @returns {Promise<Array<Webmention>>}
|
|
402
398
|
*/
|
|
403
399
|
export const retrieveWebmentions = async (options) => {
|
|
404
400
|
if (!options.domain) {
|
|
@@ -530,12 +526,12 @@ export const retrieveWebmentions = async (options) => {
|
|
|
530
526
|
return webmentions;
|
|
531
527
|
};
|
|
532
528
|
|
|
533
|
-
/** @type {Webmention
|
|
529
|
+
/** @type {Array<Webmention>} */
|
|
534
530
|
const WEBMENTIONS = {};
|
|
535
531
|
|
|
536
532
|
/**
|
|
537
533
|
* @param {Options} options
|
|
538
|
-
* @returns {Promise<{ string: Webmention
|
|
534
|
+
* @returns {Promise<{[key: string]: Array<Webmention>}>}
|
|
539
535
|
*/
|
|
540
536
|
export const webmentionsByURL = async (options) => {
|
|
541
537
|
if (Object.keys(WEBMENTIONS).length) {
|
|
@@ -569,8 +565,8 @@ export const filteredWebmentions = webmentionsByURL;
|
|
|
569
565
|
/**
|
|
570
566
|
* @param {Options} options
|
|
571
567
|
* @param {string} url
|
|
572
|
-
* @param {WebmentionType
|
|
573
|
-
* @returns {Promise<Webmention
|
|
568
|
+
* @param {WebmentionType|Array<WebmentionType>} [types]
|
|
569
|
+
* @returns {Promise<Array<Webmention>>}
|
|
574
570
|
*/
|
|
575
571
|
export const getWebmentions = async (options, url, types = []) => {
|
|
576
572
|
const webmentions = await webmentionsByURL(options);
|
|
@@ -619,7 +615,7 @@ export const getWebmentions = async (options, url, types = []) => {
|
|
|
619
615
|
|
|
620
616
|
/**
|
|
621
617
|
* @param {object} eleventyConfig
|
|
622
|
-
* @param {Options} [options
|
|
618
|
+
* @param {Options} [options]
|
|
623
619
|
*/
|
|
624
620
|
export const eleventyCacheWebmentions = async (
|
|
625
621
|
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.7",
|
|
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": {
|
|
@@ -61,14 +61,14 @@
|
|
|
61
61
|
"node": ">=18"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@11ty/eleventy-fetch": "^5.1.
|
|
64
|
+
"@11ty/eleventy-fetch": "^5.1.1",
|
|
65
65
|
"sanitize-html": "^2.17.0"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"esbuild": "^0.
|
|
69
|
-
"eslint": "^9.
|
|
70
|
-
"eslint-plugin-jsdoc": "^61.1
|
|
71
|
-
"globals": "^16.
|
|
68
|
+
"esbuild": "^0.27.1",
|
|
69
|
+
"eslint": "^9.39.1",
|
|
70
|
+
"eslint-plugin-jsdoc": "^61.4.1",
|
|
71
|
+
"globals": "^16.5.0",
|
|
72
72
|
"nock": "^14.0.10"
|
|
73
73
|
},
|
|
74
74
|
"type": "module"
|