Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
eleventy-plugin-webmentions
Advanced tools
An eleventy plugin to fetch webmentions and helper methods to display them
A plugin for eleventy to fetch and filter webmentions from Webmention.io.
Available on npm.
npm install --save-dev eleventy-plugin-webmentions
In your Eleventy config file (probably .eleventy.js
), load the plugin module and use .addPlugin
to add it to Eleventy with an options object that defines the domain
and the Webmention.io token
. Like this:
const Webmentions = require("eleventy-plugin-webmentions");
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(Webmentions, {
domain: "lukeb.co.uk",
token: "ABC123XYZ987",
});
};
REMEMBER: You’re only allowed one module.exports
in your configuration file, so make sure you only copy the require
and the .addPlugin
lines above! (Including the configuration options)
The plugin then adds 2 global data objects. One is called webmentionsLastFetched
and is a Date
object with the date that the plugin last fetched webmentions, and the other is called webmentions
and is an array of webmention objects that look similar to this:
{
type: 'entry',
author: {
type: 'card',
name: 'Zach Leatherman',
photo: 'https://webmention.io/avatar/pbs.twimg.com/d9711a9ad30ae05a761e4a728883bcbdd852cbf7d41437925b0afc47a8589795.jpg',
url: 'https://twitter.com/zachleat'
},
url: 'https://twitter.com/zachleat/status/1524800520208142337',
published: '2022-05-12T17:15:48+00:00',
'wm-received': '2022-05-13T00:05:16Z',
'wm-id': 1397424,
'wm-source': 'https://brid.gy/comment/twitter/CodeFoodPixels/1524795680966991874/1524800520208142337',
'wm-target': 'https://lukeb.co.uk/blog/2022/01/17/pixelated-rounded-corners-with-css-clip-path/',
content: {
html: 'The step-by-step here was/is incredible detailed!\n' +
'<a class="u-mention" href="http://lukeb.co.uk/"></a>\n' +
'<a class="u-mention" href="https://twitter.com/CodeFoodPixels"></a>',
text: 'The step-by-step here was/is incredible detailed!',
value: 'The step-by-step here was/is incredible detailed! <a></a> <a></a>'
},
'in-reply-to': 'https://lukeb.co.uk/blog/2022/01/17/pixelated-rounded-corners-with-css-clip-path/',
'wm-property': 'in-reply-to',
'wm-private': false
}
It also adds 2 filters:
webmentionsForPage
will return the webmentions for that page, in the structure defined by the mentionTypes
option.webmentionCountForPage
will return the number of webmentions for a page, filtered by the types used in the mentionTypes
option.Here is an example of using the filters in nunjucks:
{# Get the webmentions for the current page #}
{%- set currentPostMentions = webmentions | webmentionsForPage -%}
{# Get the webmentions for a specific page #}
{%- set postMentions = webmentions | webmentionsForPage(post.url) -%}
{# Get the webmention count for the current page #}
{%- set currentPostMentionCount = webmentions | webmentionCountForPage -%}
{# Get the webmention count for a page #}
{%- set postMentionCount = webmentions | webmentionCountForPage(post.url) -%}
Below are all the options that can be passed to the plugin:
Option | Type | Required? | Default | Description |
---|---|---|---|---|
| string |
Required |
| The domain you wish to get the webmentions for. |
| string |
Required |
| The webmention.io token (found at the bottom of [the webmention.io settings page](https://webmention.io/settings)). |
| string | Optional |
| The directory for webmentions to be cached to. |
| integer | Optional |
| The time in seconds for the cached webmentions to be considered "fresh". |
| boolean | Optional |
| Whether or not to truncate the webmentions |
| integer | Optional |
| The length to truncate webmentions to if `truncate` is true |
| string | Optional |
| The string to truncate the content with |
| boolean | Optional |
| Whether or not to return HTML content from the webmentions. If `false`, just text content will be returned. |
| boolean | Optional |
|
Whether or not to convert Twitter URLs using tweetback-canonical |
| object | Optional |
|
An object keyed by page path, with the values either being a string of a page that is an alias of that page (e.g an old page that has been redirected) or an array of strings. |
| object | Optional |
|
A single layer object with groupings and types that should be returned for that grouping. The object can have any keys you wish (doesn't have to be |
| object | Optional |
|
A set of options passed to |
| function | Optional |
| A function to use when sorting the webmentions. By default, the webmentions will be sorted in date ascending order, either by when they were published or when they were recieved. |
All of the defaults are exposed on the defaults
property of the module, so they can be used in your config if necessary.
Here is an example of extending the sanitizeOptions
object:
const Webmentions = require("eleventy-plugin-webmentions");
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(Webmentions, {
domain: "lukeb.co.uk",
token: "ABC123XYZ987",
sanitizeOptions: {
...Webmentions.defaults.sanitizeOptions,
allowedTags: [
...Webmentions.defaults.sanitizeOptions.allowedTags,
"iframe",
"marquee",
],
disallowedTagsMode: "escape",
},
});
};
FAQs
An eleventy plugin to fetch webmentions and helper methods to display them
We found that eleventy-plugin-webmentions demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.