@chrisburnell/eleventy-cache-webmentions 0.1.1 → 0.1.2

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # eleventy-cache-assets
2
2
 
3
- > Work-in-progress! ⚠️ Cache webmentions using eleventy-cache-assets and make them available to use in collections, templates, pages, etc.
3
+ > Cache webmentions using eleventy-cache-assets and make them available to use in collections, templates, pages, etc.
4
4
 
5
5
  ## Installation
6
6
 
@@ -93,7 +93,7 @@ module.exports = (config, options = {}) => {
93
93
  return Promise.reject(response)
94
94
  })
95
95
  .catch((error) => {
96
- console.log("Something went wrong with your request to webmention.io!", error)
96
+ console.log("[${hostname(options.domain)}] Something went wrong with your request to webmention.io!", error)
97
97
  })
98
98
  }
99
99
 
@@ -126,7 +126,7 @@ module.exports = (config, options = {}) => {
126
126
  return webmentions
127
127
  }
128
128
 
129
- const getWebmentions = async (url, allowedTypes) => {
129
+ const getWebmentions = async (url, allowedTypes = {}) => {
130
130
  const webmentions = await filteredWebmentions()
131
131
  url = absoluteURL(url, options.domain)
132
132
 
@@ -137,7 +137,7 @@ module.exports = (config, options = {}) => {
137
137
  const results = webmentions[url]
138
138
  // filter webmentions by allowed response post types
139
139
  .filter((entry) => {
140
- return Array.isArray(allowedTypes) ? allowedTypes.includes(entry["wm-property"]) : true
140
+ return typeof allowedTypes === "object" && Object.keys(allowedTypes).length ? allowedTypes.includes(entry["wm-property"]) : true
141
141
  })
142
142
  // remove webmentions without an author name
143
143
  .filter((entry) => {
@@ -166,12 +166,12 @@ module.exports = (config, options = {}) => {
166
166
  }
167
167
 
168
168
  const getWebmentionsFilter = async (url, allowedTypes, callback) => {
169
- const webmentions = await getWebmentions(url, allowedTypes)
170
- if (typeof callback === "function") {
171
- callback(null, webmentions)
172
- } else {
173
- return webmentions
169
+ if (typeof callback !== "function") {
170
+ callback = allowedTypes
171
+ allowedTypes = {}
174
172
  }
173
+ const webmentions = await getWebmentions(url, allowedTypes)
174
+ callback(null, webmentions)
175
175
  }
176
176
 
177
177
  if (config && options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chrisburnell/eleventy-cache-webmentions",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Cache webmentions from webmention.io using eleventy-cache-assets.",
5
5
  "main": "eleventy-cache-webmentions.js",
6
6
  "author": "Chris Burnell <me@chrisburnell.com>",