@chrisburnell/eleventy-cache-webmentions 1.2.6-rc.2 → 2.0.0
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 +181 -106
- package/eleventy-cache-webmentions.js +51 -30
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
# eleventy-cache-webmentions
|
|
2
2
|
|
|
3
|
-
> Cache webmentions using eleventy-fetch and make them available to use in collections,
|
|
3
|
+
> Cache webmentions using eleventy-fetch and make them available to use in collections, layouts, pages, etc. in Eleventy.
|
|
4
4
|
|
|
5
5
|
## Quick Guide
|
|
6
6
|
|
|
7
|
-
I wrote a quicker and simpler guide to getting this Eleventy plugin working that cuts out all the fluff and extra details.
|
|
7
|
+
I wrote a quicker and simpler guide to getting this Eleventy plugin working that cuts out all the fluff and extra details.
|
|
8
|
+
|
|
9
|
+
Check it out: [Webmention Setup for Eleventy](https://chrisburnell.com/article/webmention-eleventy-setup/).
|
|
8
10
|
|
|
9
11
|
## Installation
|
|
10
12
|
|
|
11
13
|
- **With npm:** `npm install @chrisburnell/eleventy-cache-webmentions`
|
|
12
14
|
- **Direct download:** [https://github.com/chrisburnell/eleventy-cache-webmentions/archive/master.zip](https://github.com/chrisburnell/eleventy-cache-webmentions/archive/master.zip)
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
### Add it to your config
|
|
17
|
-
|
|
18
|
-
Inside your Eleventy config file (typically `.eleventy.js`), use `addPlugin`:
|
|
16
|
+
Inside your Eleventy config file, use `addPlugin()` to add it to your project:
|
|
19
17
|
|
|
20
18
|
```javascript
|
|
21
19
|
const pluginWebmentions = require("@chrisburnell/eleventy-cache-webmentions")
|
|
22
20
|
|
|
23
|
-
module.exports = function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
module.exports = function(eleventyConfig) {
|
|
22
|
+
eleventyConfig.addPlugin(pluginWebmentions, {
|
|
23
|
+
// These 3 fields are all required!
|
|
24
|
+
domain: "https://example.com",
|
|
25
|
+
feed: "https://webmentions.example.com?token=S3cr3tT0k3n",
|
|
26
|
+
key: "array_of_webmentions"
|
|
27
|
+
})
|
|
30
28
|
}
|
|
31
29
|
```
|
|
32
30
|
|
|
33
|
-
|
|
31
|
+
Make sure you get the correct values for this configuration. Check below for both Webmention.io configuration and go-jamming configuration.
|
|
34
32
|
|
|
33
|
+
<details>
|
|
34
|
+
<summary>Full options list</summary>
|
|
35
35
|
<table>
|
|
36
36
|
<thead>
|
|
37
37
|
<tr>
|
|
@@ -116,124 +116,193 @@ module.exports = function (eleventyConfig) {
|
|
|
116
116
|
</tr>
|
|
117
117
|
</tbody>
|
|
118
118
|
</table>
|
|
119
|
+
</details>
|
|
120
|
+
|
|
121
|
+
## Usage
|
|
122
|
+
|
|
123
|
+
`eleventy-cache-webmentions` comes with a number of ways of accessing your Webmentions as [Global Data](https://www.11ty.dev/docs/data-global-custom/) in both JavaScript and Liquid/Nunjucks as well as a series of [Eleventy Filters](https://www.11ty.dev/docs/filters/) and JavaScript Functions for filtering, sorting, and reading properties about each Webmention:
|
|
119
124
|
|
|
120
|
-
|
|
125
|
+
### Global Data
|
|
126
|
+
|
|
127
|
+
<details>
|
|
128
|
+
<summary>JavaScript</summary>
|
|
121
129
|
|
|
122
130
|
```javascript
|
|
123
|
-
const
|
|
131
|
+
const {
|
|
132
|
+
defaults, // default options for the plugin
|
|
133
|
+
webmentionsByUrl, // Object containing Arrays of Webmentions by URL
|
|
134
|
+
} = require("@chrisburnell/eleventy-cache-webmentions")
|
|
135
|
+
```
|
|
124
136
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
allowedAttributes: {
|
|
136
|
-
a: ["href"],
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
allowlist: [],
|
|
140
|
-
blocklist: [],
|
|
141
|
-
urlReplacements: {},
|
|
142
|
-
maximumHtmlLength: 2000,
|
|
143
|
-
maximumHtmlText: "mentioned this in",
|
|
144
|
-
})
|
|
145
|
-
}
|
|
137
|
+
</details>
|
|
138
|
+
|
|
139
|
+
<details>
|
|
140
|
+
<summary>Liquid / Nunjucks</summary>
|
|
141
|
+
|
|
142
|
+
```twig
|
|
143
|
+
{# default options for the plugin #}
|
|
144
|
+
{{ webmentionsDefaults }}
|
|
145
|
+
{# Object containing Arrays of Webmentions by URL #}
|
|
146
|
+
{{ webmentionsByUrl }}
|
|
146
147
|
```
|
|
147
148
|
|
|
148
|
-
|
|
149
|
+
</details>
|
|
150
|
+
|
|
151
|
+
### Filters
|
|
149
152
|
|
|
150
|
-
|
|
153
|
+
<details>
|
|
154
|
+
<summary>JavaScript</summary>
|
|
151
155
|
|
|
152
156
|
```javascript
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
+
const {
|
|
158
|
+
getWebmentions, // get Array of Webmentions for a given URL
|
|
159
|
+
getByTypes, // filter Webmentions by their response type
|
|
160
|
+
getPublished, // get received/published time of a Webmention
|
|
161
|
+
getContent, // get content of a Webmention
|
|
162
|
+
getSource, // get source URL of a Webmention (where it's from)
|
|
163
|
+
getTarget, // get target URL of a Webmention (where it's sent to)
|
|
164
|
+
getType, // get response type of a Webmention
|
|
165
|
+
} = require("@chrisburnell/eleventy-cache-webmentions")
|
|
166
|
+
|
|
167
|
+
// This is NOT the best way to get Webmentions!
|
|
168
|
+
// See "Attach Webmentions to Pages using Directory Data" below.
|
|
169
|
+
const webmentions = getWebmentions({
|
|
170
|
+
domain: "https://example.com",
|
|
171
|
+
feed: "https://webmentions.example.com?token=S3cr3tT0k3n",
|
|
172
|
+
key: "array_of_webmentions"
|
|
173
|
+
}, "https://example.com/specific-page/")
|
|
174
|
+
|
|
175
|
+
const responsesOnly = getByTypes(webmentions, ['mention-of', 'in-reply-to'])
|
|
176
|
+
|
|
177
|
+
webmentions.forEach((webmention) => {
|
|
178
|
+
const published = getPublished(webmention)
|
|
179
|
+
const content = getContent(webmention)
|
|
180
|
+
const source = getSource(webmention)
|
|
181
|
+
const target = getTarget(webmention)
|
|
182
|
+
const type = getType(webmention)
|
|
157
183
|
})
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
</details>
|
|
158
187
|
|
|
159
|
-
|
|
188
|
+
<details>
|
|
189
|
+
<summary>Liquid / Nunjucks</summary>
|
|
190
|
+
|
|
191
|
+
```twig
|
|
192
|
+
{# get Array of Webmentions for a given URL #}
|
|
193
|
+
{% set webmentions = ("https://example.com" + page.url) | getWebmentions %}
|
|
194
|
+
|
|
195
|
+
{# filter Webmentions by their response type #}
|
|
196
|
+
{{ set responses = webmentions | getWebmentionsByTypes(['mention-of', 'in-reply-to']) }}
|
|
197
|
+
|
|
198
|
+
{% for webmention in webmentions %}
|
|
199
|
+
{# get received/published time of a Webmention #}
|
|
200
|
+
{{ webmentions | getWebmentionPublished }}
|
|
201
|
+
{# get content of a Webmention #}
|
|
202
|
+
{{ webmentions | getWebmentionContent }}
|
|
203
|
+
{# get source URL of a Webmention (where it's from) #}
|
|
204
|
+
{{ webmentions | getWebmentionSource }}
|
|
205
|
+
{# get target URL of a Webmention (where it's sent to) #}
|
|
206
|
+
{{ webmentions | getWebmentionTarget }}
|
|
207
|
+
{# get response type of a Webmention #}
|
|
208
|
+
{{ webmentions | getWebmentionType }}
|
|
209
|
+
{% endfor %}
|
|
160
210
|
```
|
|
161
211
|
|
|
162
|
-
|
|
212
|
+
</details>
|
|
163
213
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
})
|
|
214
|
+
## Attach Webmentions to Pages using Directory Data
|
|
215
|
+
|
|
216
|
+
Using [Eleventy’s Data Cascade](https://www.11ty.dev/docs/data-cascade/), you can attach Webmentions to each page by using [Directory Specific Data Files](https://www.11ty.dev/docs/data-template-dir/).
|
|
217
|
+
|
|
218
|
+
For example, if you have a folder, `/pages/`, and want to attach Webmentions to each page, create or add the following to a `pages.11tydata.js` file within the folder:
|
|
170
219
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
220
|
+
```javascript
|
|
221
|
+
const { getWebmentions, getPublished } = require("@chrisburnell/eleventy-cache-webmentions")
|
|
222
|
+
|
|
223
|
+
module.exports = {
|
|
224
|
+
eleventyComputed: {
|
|
225
|
+
webmentions: (data) => {
|
|
226
|
+
// Get this page's Webmentions as an Array (based on the URL)
|
|
227
|
+
const webmentionsForUrl = getWebmentions({
|
|
228
|
+
domain: "https://example.com",
|
|
229
|
+
feed: "https://webmentions.example.com?token=S3cr3tT0k3n",
|
|
230
|
+
key: "array_of_webmentions"
|
|
231
|
+
}, "https://example.com" + data.page.url)
|
|
232
|
+
|
|
233
|
+
// If there are Webmentions for this page
|
|
234
|
+
if (webmentionsForUrl.length) {
|
|
235
|
+
// Sort them (based on when they were received/published)
|
|
236
|
+
return webmentionsForUrl.sort((a, b) => {
|
|
237
|
+
return getPublished(b) - getPublished(a)
|
|
238
|
+
})
|
|
239
|
+
}
|
|
240
|
+
// Otherwise, return an empty Array
|
|
241
|
+
return []
|
|
242
|
+
},
|
|
243
|
+
},
|
|
188
244
|
}
|
|
189
245
|
```
|
|
190
246
|
|
|
191
|
-
|
|
247
|
+
This attaches an Array containing Webmentions to each page (based on its URL). You can then access this Array of Webmentions with the variable, <samp>webmentions</samp>, within a [Layout](https://www.11ty.dev/docs/layouts/), [Include](https://www.11ty.dev/docs/includes/), or from the page itself:
|
|
248
|
+
|
|
249
|
+
```twig
|
|
250
|
+
{% for webmention in webmentions %}
|
|
251
|
+
{# Do something with each Webmention #}
|
|
252
|
+
{% endfor %}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
These Arrays of Webmentions can even be accessed when building [Collections](https://www.11ty.dev/docs/collections/), allowing you to create a Collection of pages sorted by their number of Webmentions, for example:
|
|
192
256
|
|
|
193
257
|
```javascript
|
|
194
258
|
module.exports = (eleventyConfig) => {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
259
|
+
eleventyConfig.addCollection("popular", (collection) => {
|
|
260
|
+
return collection
|
|
261
|
+
.sort((a, b) => {
|
|
262
|
+
return b.data.webmentions.length - a.data.webmentions.length
|
|
263
|
+
})
|
|
264
|
+
})
|
|
200
265
|
}
|
|
201
266
|
```
|
|
202
267
|
|
|
203
|
-
##
|
|
268
|
+
## Without Directory Data
|
|
204
269
|
|
|
205
|
-
|
|
270
|
+
If you would rather get Webmentions for a given page directly from a Layout/Include/Page itself, you can do so using the Filter, `getWebmentions`:
|
|
206
271
|
|
|
207
272
|
```twig
|
|
208
|
-
{%
|
|
273
|
+
{% set webmentions = ("https://example.com" + page.url) | getWebmentions %}
|
|
274
|
+
{% for webmention in webmentions %}
|
|
275
|
+
...
|
|
276
|
+
{% endfor %}
|
|
209
277
|
```
|
|
210
278
|
|
|
211
|
-
|
|
279
|
+
## Get specific types of Webmentions
|
|
212
280
|
|
|
213
|
-
|
|
214
|
-
{% raw %}{% set responses = page.url | getWebmentions %}{% endraw %}
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
You can get back only specific [response post types](https://indieweb.org/responses#Response_Post_Types) by passing a second argument:
|
|
281
|
+
Instead of getting all the Webmentions for a given page, you may want to grab only certain types of Webmentions. This is useful if you want to display different types of Webmentions separately, e.g.:
|
|
218
282
|
|
|
219
283
|
```twig
|
|
220
|
-
{%
|
|
221
|
-
{% set
|
|
284
|
+
{% set bookmarks = webmentions | getTypes(['bookmark-of']) %}
|
|
285
|
+
{% set likes = webmentions | getTypes(['like-of']) %}
|
|
286
|
+
{% set reposts = webmentions | getTypes(['repost-of']) %}
|
|
287
|
+
|
|
288
|
+
{% set replies = webmentions | getTypes(['mention-of', 'in-reply-to']) %}
|
|
222
289
|
```
|
|
223
290
|
|
|
224
|
-
|
|
291
|
+
## Get all Webmentions at once
|
|
292
|
+
|
|
293
|
+
If you need it, the plugin also makes available an Object containing your cached Webmentions organised in key:value pairs, where each key is a full URL on your website and its value is an Array of Webmentions sent to that URL:
|
|
225
294
|
|
|
226
295
|
```twig
|
|
227
|
-
{%
|
|
228
|
-
{% for url, array in
|
|
229
|
-
|
|
296
|
+
{% set count = 0 %}
|
|
297
|
+
{% for url, array in webmentionsByUrl %}
|
|
298
|
+
{% set count = array.length + count %}
|
|
230
299
|
{% endfor %}
|
|
231
|
-
<p>This
|
|
300
|
+
<p>This website has received {{ count }} Webmentions!</p>
|
|
232
301
|
```
|
|
233
302
|
|
|
234
|
-
|
|
303
|
+
## Webmention.io
|
|
235
304
|
|
|
236
|
-
[Webmention.io](https://webmention.io) is a in-place Webmention receiver solution that you can use by authenticating yourself via [IndieAuth](https://indieauth.com/) (or host it yourself), and, like so much other
|
|
305
|
+
[Webmention.io](https://webmention.io) is a in-place Webmention receiver solution that you can use by authenticating yourself via [IndieAuth](https://indieauth.com/) (or host it yourself), and, like *so much* other publicly-available IndieWeb software, is built and hosted by [Aaron Parecki](https://aaronparecki.com/).
|
|
237
306
|
|
|
238
307
|
### Add your token
|
|
239
308
|
|
|
@@ -245,25 +314,31 @@ WEBMENTION_IO_TOKEN=njJql0lKXnotreal4x3Wmd
|
|
|
245
314
|
|
|
246
315
|
### Set your feed and key config options
|
|
247
316
|
|
|
317
|
+
The example below requests the [JF2](https://www.w3.org/TR/jf2/) file format, which I highly recommend using; although, there is a JSON format available from [Webmention.io](https://webmention.io) as well. The [official documentation](https://github.com/aaronpk/webmention.io) has more information on how to use these two formats.
|
|
318
|
+
|
|
319
|
+
The key difference between the two feed formats is in the *naming* of the keys: the JF2 format holds the array of Webmentions in the `children` key, whereas the JSON format holds them in the `links` key. The JF2 format, however, provides keys and values that more tightly-align with [microformats](https://indieweb.org/microformats), the method I recommend the most for marking up HTML such that it can be consumed and understood by <q>search engines, aggregators, and other tools</q> across the Indieweb.
|
|
320
|
+
|
|
248
321
|
```javascript
|
|
249
322
|
const pluginWebmentions = require("@chrisburnell/eleventy-cache-webmentions")
|
|
250
323
|
|
|
251
|
-
module.exports = function
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
324
|
+
module.exports = function(eleventyConfig) {
|
|
325
|
+
eleventyConfig.addPlugin(pluginWebmentions, {
|
|
326
|
+
domain: "https://example.com",
|
|
327
|
+
feed: `https://webmention.io/api/mentions.jf2?domain=example.com&per-page=9001&token=${process.env.WEBMENTION_IO_TOKEN}`,
|
|
328
|
+
key: "children"
|
|
329
|
+
})
|
|
257
330
|
}
|
|
258
331
|
```
|
|
259
332
|
|
|
333
|
+
If you want to use the JSON format instead, make sure that you replace `mentions.jf2` in the URL with `mentions.json` and change the value of the key from `children` to `links`.
|
|
334
|
+
|
|
260
335
|
## go-jamming
|
|
261
336
|
|
|
262
337
|
[go-jamming](https://git.brainbaking.com/wgroeneveld/go-jamming) is a self-hosted Webmention sender and receiver, built in Go by [Wouter Groeneveld](https://brainbaking.com) and available with more information on his [personal git instance](https://git.brainbaking.com/wgroeneveld/go-jamming).
|
|
263
338
|
|
|
264
339
|
### Add your token
|
|
265
340
|
|
|
266
|
-
Once you’ve set up your
|
|
341
|
+
Once you’ve set up your *go-jamming* server and you’ve defined your token, you’ll need add it to your project as an environment variable, i.e. in a `.env` file in the root of your project:
|
|
267
342
|
|
|
268
343
|
```text
|
|
269
344
|
GO_JAMMING_TOKEN=njJql0lKXnotreal4x3Wmd
|
|
@@ -274,12 +349,12 @@ GO_JAMMING_TOKEN=njJql0lKXnotreal4x3Wmd
|
|
|
274
349
|
```javascript
|
|
275
350
|
const pluginWebmentions = require("@chrisburnell/eleventy-cache-webmentions")
|
|
276
351
|
|
|
277
|
-
module.exports = function
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
352
|
+
module.exports = function(eleventyConfig) {
|
|
353
|
+
eleventyConfig.addPlugin(pluginWebmentions, {
|
|
354
|
+
domain: "https://example.com",
|
|
355
|
+
feed: `https://jam.example.com/webmention/example.com/${process.env.GO_JAMMING_TOKEN}`,
|
|
356
|
+
key: "json"
|
|
357
|
+
})
|
|
283
358
|
}
|
|
284
359
|
```
|
|
285
360
|
|
|
@@ -38,7 +38,7 @@ const epoch = (value) => {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
const getPublished = (webmention) => {
|
|
41
|
-
return webmention["
|
|
41
|
+
return webmention?.["data"]?.["published"] || webmention["published"] || webmention["wm-received"] || webmention["verified_date"]
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
const getContent = (webmention) => {
|
|
@@ -46,7 +46,7 @@ const getContent = (webmention) => {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
const getSource = (webmention) => {
|
|
49
|
-
return webmention["url"] || webmention
|
|
49
|
+
return webmention?.["data"]?.["url"] || webmention["url"] || webmention["wm-source"] || webmention["source"]
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
const getTarget = (webmention) => {
|
|
@@ -54,7 +54,13 @@ const getTarget = (webmention) => {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
const getType = (webmention) => {
|
|
57
|
-
return webmention["wm-property"] || webmention?.["activity"]["type"] || webmention["type"]
|
|
57
|
+
return webmention["wm-property"] || webmention?.["activity"]?.["type"] || webmention["type"]
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const getByTypes = (webmentions, allowedTypes) => {
|
|
61
|
+
return webmentions.filter((webmention) => {
|
|
62
|
+
return allowedTypes.includes(getType(webmention))
|
|
63
|
+
})
|
|
58
64
|
}
|
|
59
65
|
|
|
60
66
|
const defaults = {
|
|
@@ -97,15 +103,17 @@ const fetchWebmentions = async (options) => {
|
|
|
97
103
|
}
|
|
98
104
|
|
|
99
105
|
// If there is a cached file but it is outside of expiry, fetch fresh
|
|
100
|
-
// results since the most recent
|
|
106
|
+
// results since the most recent Webmention
|
|
101
107
|
if (!asset.isCacheValid(options.duration)) {
|
|
108
|
+
// Get the published date of the most recent Webmention, if it exists
|
|
102
109
|
const since = webmentions.length ? getPublished(webmentions[0]) : false
|
|
110
|
+
// Build the URL for the fetch request
|
|
103
111
|
const url = `${options.feed}${since ? `${options.feed.includes("?") ? "&" : "?"}since=${since}` : ""}`
|
|
104
112
|
await fetch(url).then(async (response) => {
|
|
105
113
|
if (response.ok) {
|
|
106
114
|
const feed = await response.json()
|
|
107
115
|
if (feed[options.key].length) {
|
|
108
|
-
// Combine newly-fetched
|
|
116
|
+
// Combine newly-fetched Webmentions with cached Webmentions
|
|
109
117
|
webmentions = feed[options.key].concat(webmentions)
|
|
110
118
|
// Remove duplicates by source URL
|
|
111
119
|
webmentions = uniqBy([...feed[options.key], ...webmentions], (webmention) => {
|
|
@@ -172,9 +180,6 @@ const filteredWebmentions = async (options) => {
|
|
|
172
180
|
filtered[url].push(webmention)
|
|
173
181
|
})
|
|
174
182
|
|
|
175
|
-
const filteredCount = Object.values(filtered).reduce((count, webmentions) => count + webmentions.length, 0)
|
|
176
|
-
console.log(`[${hostname(options.domain)}] ${filteredCount} filtered Webmentions pulled from cache.`)
|
|
177
|
-
|
|
178
183
|
return filtered
|
|
179
184
|
}
|
|
180
185
|
|
|
@@ -221,28 +226,44 @@ const getWebmentionsFilter = async (options, url, allowedTypes, callback) => {
|
|
|
221
226
|
callback(null, webmentions)
|
|
222
227
|
}
|
|
223
228
|
|
|
224
|
-
|
|
229
|
+
const eleventyCacheWebmentions = (eleventyConfig, options = {}) => {
|
|
225
230
|
options = Object.assign(defaults, options)
|
|
226
231
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
232
|
+
// Global Data
|
|
233
|
+
eleventyConfig.addGlobalData("webmentionsDefaults", defaults)
|
|
234
|
+
const filtered = async () => await filteredWebmentions(options)
|
|
235
|
+
eleventyConfig.addGlobalData("webmentionsByUrl", filtered)
|
|
236
|
+
const unfiltered = async () => await filteredWebmentions(options).then((filtered) => Object.values(filtered).reduce((array, webmentions) => [...array, ...webmentions], []))
|
|
237
|
+
eleventyConfig.addGlobalData("webmentionsAll", unfiltered)
|
|
238
|
+
|
|
239
|
+
// Liquid Filters
|
|
240
|
+
eleventyConfig.addLiquidFilter("getWebmentions", getWebmentionsFilter)
|
|
241
|
+
eleventyConfig.addLiquidFilter("getWebmentionPublished", getPublished)
|
|
242
|
+
eleventyConfig.addLiquidFilter("getWebmentionContent", getContent)
|
|
243
|
+
eleventyConfig.addLiquidFilter("getWebmentionSource", getSource)
|
|
244
|
+
eleventyConfig.addLiquidFilter("getWebmentionTarget", getTarget)
|
|
245
|
+
eleventyConfig.addLiquidFilter("getWebmentionType", getType)
|
|
246
|
+
eleventyConfig.addLiquidFilter("getWebmentionsByTypes", getByTypes)
|
|
247
|
+
|
|
248
|
+
// Nunjucks Filters
|
|
249
|
+
eleventyConfig.addNunjucksAsyncFilter("getWebmentions", getWebmentionsFilter)
|
|
250
|
+
eleventyConfig.addNunjucksFilter("getWebmentionsByTypes", getByTypes)
|
|
251
|
+
eleventyConfig.addNunjucksFilter("getWebmentionPublished", getPublished)
|
|
252
|
+
eleventyConfig.addNunjucksFilter("getWebmentionContent", getContent)
|
|
253
|
+
eleventyConfig.addNunjucksFilter("getWebmentionSource", getSource)
|
|
254
|
+
eleventyConfig.addNunjucksFilter("getWebmentionTarget", getTarget)
|
|
255
|
+
eleventyConfig.addNunjucksFilter("getWebmentionType", getType)
|
|
248
256
|
}
|
|
257
|
+
|
|
258
|
+
module.exports = eleventyCacheWebmentions
|
|
259
|
+
module.exports.defaults = defaults
|
|
260
|
+
module.exports.filteredWebmentions = filteredWebmentions
|
|
261
|
+
module.exports.webmentionsByUrl = filteredWebmentions
|
|
262
|
+
module.exports.fetchWebmentions = fetchWebmentions
|
|
263
|
+
module.exports.getWebmentions = getWebmentions
|
|
264
|
+
module.exports.getByTypes = getByTypes
|
|
265
|
+
module.exports.getPublished = getPublished
|
|
266
|
+
module.exports.getContent = getContent
|
|
267
|
+
module.exports.getSource = getSource
|
|
268
|
+
module.exports.getTarget = getTarget
|
|
269
|
+
module.exports.getType = getType
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chrisburnell/eleventy-cache-webmentions",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Cache webmentions using eleventy-fetch and make them available to use in collections, layouts, pages, etc. in Eleventy.",
|
|
5
5
|
"author": "Chris Burnell <me@chrisburnell.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"webmention"
|
|
21
21
|
],
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"eslint": "^8.
|
|
23
|
+
"eslint": "^8.56.0"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@11ty/eleventy-fetch": "^4.0.0",
|