@chrisburnell/eleventy-cache-webmentions 2.1.3 → 2.1.5
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.
|
@@ -72,6 +72,15 @@ const getContent = (webmention) => {
|
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
const getSource = (webmention) => {
|
|
75
|
+
return (
|
|
76
|
+
webmention["wm-source"] ||
|
|
77
|
+
webmention["source"] ||
|
|
78
|
+
webmention?.["data"]?.["url"] ||
|
|
79
|
+
webmention["url"]
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const getURL = (webmention) => {
|
|
75
84
|
return (
|
|
76
85
|
webmention?.["data"]?.["url"] ||
|
|
77
86
|
webmention["url"] ||
|
|
@@ -153,9 +162,13 @@ const performFetch = async (options, webmentions, url) => {
|
|
|
153
162
|
// Process the blocklist, if it has any entries
|
|
154
163
|
if (options.blocklist.length) {
|
|
155
164
|
webmentions = webmentions.filter((webmention) => {
|
|
156
|
-
let
|
|
157
|
-
|
|
158
|
-
|
|
165
|
+
let url = getSource(webmention);
|
|
166
|
+
let source = getSource(webmention);
|
|
167
|
+
for (let blocklistURL of options.blocklist) {
|
|
168
|
+
if (
|
|
169
|
+
url.includes(blocklistURL.replace(/\/?$/, "/")) ||
|
|
170
|
+
source.includes(blocklistURL.replace(/\/?$/, "/"))
|
|
171
|
+
) {
|
|
159
172
|
return false;
|
|
160
173
|
}
|
|
161
174
|
}
|
|
@@ -165,9 +178,13 @@ const performFetch = async (options, webmentions, url) => {
|
|
|
165
178
|
// Process the allowlist, if it has any entries
|
|
166
179
|
if (options.allowlist.length) {
|
|
167
180
|
webmentions = webmentions.filter((webmention) => {
|
|
168
|
-
let
|
|
169
|
-
|
|
170
|
-
|
|
181
|
+
let url = getSource(webmention);
|
|
182
|
+
let source = getSource(webmention);
|
|
183
|
+
for (let allowlistURL of options.allowlist) {
|
|
184
|
+
if (
|
|
185
|
+
url.includes(allowlistURL.replace(/\/?$/, "/")) ||
|
|
186
|
+
source.includes(allowlistURL.replace(/\/?$/, "/"))
|
|
187
|
+
) {
|
|
171
188
|
return true;
|
|
172
189
|
}
|
|
173
190
|
}
|
|
@@ -399,6 +416,7 @@ const eleventyCacheWebmentions = (eleventyConfig, options = {}) => {
|
|
|
399
416
|
eleventyConfig.addLiquidFilter("getWebmentionReceived", getReceived);
|
|
400
417
|
eleventyConfig.addLiquidFilter("getWebmentionContent", getContent);
|
|
401
418
|
eleventyConfig.addLiquidFilter("getWebmentionSource", getSource);
|
|
419
|
+
eleventyConfig.addLiquidFilter("getWebmentionURL", getURL);
|
|
402
420
|
eleventyConfig.addLiquidFilter("getWebmentionTarget", getTarget);
|
|
403
421
|
eleventyConfig.addLiquidFilter("getWebmentionType", getType);
|
|
404
422
|
|
|
@@ -409,6 +427,7 @@ const eleventyCacheWebmentions = (eleventyConfig, options = {}) => {
|
|
|
409
427
|
eleventyConfig.addNunjucksFilter("getWebmentionReceived", getReceived);
|
|
410
428
|
eleventyConfig.addNunjucksFilter("getWebmentionContent", getContent);
|
|
411
429
|
eleventyConfig.addNunjucksFilter("getWebmentionSource", getSource);
|
|
430
|
+
eleventyConfig.addNunjucksFilter("getWebmentionURL", getURL);
|
|
412
431
|
eleventyConfig.addNunjucksFilter("getWebmentionTarget", getTarget);
|
|
413
432
|
eleventyConfig.addNunjucksFilter("getWebmentionType", getType);
|
|
414
433
|
};
|
|
@@ -431,6 +450,8 @@ module.exports.getContent = getContent;
|
|
|
431
450
|
module.exports.getWebmentionContent = getContent;
|
|
432
451
|
module.exports.getSource = getSource;
|
|
433
452
|
module.exports.getWebmentionSource = getSource;
|
|
453
|
+
module.exports.getURL = getURL;
|
|
454
|
+
module.exports.getWebmentionURL = getURL;
|
|
434
455
|
module.exports.getTarget = getTarget;
|
|
435
456
|
module.exports.getWebmentionTarget = getTarget;
|
|
436
457
|
module.exports.getType = getType;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chrisburnell/eleventy-cache-webmentions",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.5",
|
|
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": {
|