Skip to content

Commit da78f48

Browse files
authored
✨ add webmentions feature (#91)
* add webmention and pingback links * add sample environment * ignore `.env` file * add webmention and dotenv packages * add webmentions plugin and configure * add webmentions output to content page * add dotenv * ignore webmention cache
1 parent 83b342d commit da78f48

6 files changed

Lines changed: 19 additions & 2 deletions

File tree

.eleventy.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
require('dotenv').config();
2+
const Webmentions = require("eleventy-plugin-webmentions");
13
const pluginRss = require("@11ty/eleventy-plugin-rss");
24
const htmlmin = require("html-minifier");
35

46
module.exports = function(eleventyConfig) {
57
// 11ty plugins
68
eleventyConfig.addPlugin(pluginRss);
9+
eleventyConfig.addPlugin(Webmentions, {
10+
domain: "benkutil.com",
11+
token: process.env.WEBMENTIONS_TOKEN
12+
});
713

814
// run these configs in production only
915
if (process.env.ELEVENTY_ENV === 'production' ) {

.env.sample

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ELEVENTY_ENV=environment
2+
WEBMENTIONS_TOKEN=yourWebmentionTokenHere

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.env
12
node_modules
23
package-lock.json
34
_site
5+
_webmentioncache

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@
2222
"devDependencies": {
2323
"@11ty/eleventy": "^2.0.0-beta.3",
2424
"@11ty/eleventy-plugin-rss": "^1.2.0",
25+
"eleventy-plugin-webmentions": "^2.0.0",
2526
"html-minifier": "^4.0.0"
2627
},
2728
"dependencies": {
28-
"@11ty/eleventy-upgrade-help": "^2.0.5"
29+
"@11ty/eleventy-upgrade-help": "^2.0.5",
30+
"dotenv": "^16.0.3"
2931
}
3032
}

src/_includes/layouts/base.njk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313

1414
<link rel="canonical" href="{{ page.url | absoluteUrl(siteData.url) }}">
1515
<link rel="alternate" type="application/rss+xml" title="{{ siteData.title | safe }}" href="{{ '/feed.xml' | absoluteUrl(siteData.url) }}">
16+
17+
<link rel="webmention" href="https://webmention.io/benkutil.com/webmention" />
18+
<link rel="pingback" href="https://webmention.io/benkutil.com/xmlrpc" />
19+
1620
<style type="text/css">
1721
html { margin: 0; padding: 0; text-align: center; }
1822
body {

src/_includes/layouts/content.njk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
layout: layouts/base.njk
33
templateClass: tmpl-content
44
---
5-
{{ content | safe }}
5+
{{ content | safe }}
6+
{%- set currentPostMentions = webmentions | webmentionsForPage -%}

0 commit comments

Comments
 (0)