Skip to content

Commit

Permalink
feat: amend getSource filter; add getURL filter
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisburnell committed Aug 13, 2024
1 parent caf31ae commit 9f2ed54
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions eleventy-cache-webmentions.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ const getContent = (webmention) => {
};

const getSource = (webmention) => {
return (
webmention["wm-source"] ||
webmention["source"] ||
webmention?.["data"]?.["url"] ||
webmention["url"]
);
};

const getURL = (webmention) => {
return (
webmention?.["data"]?.["url"] ||
webmention["url"] ||
Expand Down Expand Up @@ -399,6 +408,7 @@ const eleventyCacheWebmentions = (eleventyConfig, options = {}) => {
eleventyConfig.addLiquidFilter("getWebmentionReceived", getReceived);
eleventyConfig.addLiquidFilter("getWebmentionContent", getContent);
eleventyConfig.addLiquidFilter("getWebmentionSource", getSource);
eleventyConfig.addLiquidFilter("getWebmentionURL", getURL);
eleventyConfig.addLiquidFilter("getWebmentionTarget", getTarget);
eleventyConfig.addLiquidFilter("getWebmentionType", getType);

Expand All @@ -409,6 +419,7 @@ const eleventyCacheWebmentions = (eleventyConfig, options = {}) => {
eleventyConfig.addNunjucksFilter("getWebmentionReceived", getReceived);
eleventyConfig.addNunjucksFilter("getWebmentionContent", getContent);
eleventyConfig.addNunjucksFilter("getWebmentionSource", getSource);
eleventyConfig.addNunjucksFilter("getWebmentionURL", getURL);
eleventyConfig.addNunjucksFilter("getWebmentionTarget", getTarget);
eleventyConfig.addNunjucksFilter("getWebmentionType", getType);
};
Expand All @@ -431,6 +442,8 @@ module.exports.getContent = getContent;
module.exports.getWebmentionContent = getContent;
module.exports.getSource = getSource;
module.exports.getWebmentionSource = getSource;
module.exports.getURL = getURL;
module.exports.getWebmentionURL = getURL;
module.exports.getTarget = getTarget;
module.exports.getWebmentionTarget = getTarget;
module.exports.getType = getType;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@chrisburnell/eleventy-cache-webmentions",
"version": "2.1.3",
"version": "2.1.4",
"description": "Cache webmentions using eleventy-fetch and make them available to use in collections, layouts, pages, etc. in Eleventy.",
"license": "MIT",
"repository": {
Expand Down

0 comments on commit 9f2ed54

Please sign in to comment.