Dispatching Webmentions with a Netlify build plugin
This site uses a static site generator to build plain HTML pages. Since there's no database to add, update, or delete pages from, determining when to dispatch mentions can be challenging! Here's how I use a Netlify build plugin and an atom feed to manage it.
The Webmention spec requires that a mention should be sent whenever a link is added or removed from a page, or the page one is on is updated or deleted. The recipient will receive an HTTP post which looks the same whatever happened. It's up to them to determine what changed.
Netlify provides hooks for various stages of the build, and a plugin may use as
many as it needs. I use the
onSuccess hooks. The former is
called when the build is complete, but before it is deployed. This gives me
access to the old atom feed and pages over the network (the old version of the
site is still deployed), and new versions in the build directory. Mentions are
gathered and kept until the
onSuccess hook. This hook fires when the site is
deployed. It's important to wait for the deployment because the receiver of a
mention may automatically check the content of the source URL to know what
If you prefer to read code, check it out here.
This is just the beginning! I plan to port other capabilities over to Netlify build plugins in time.
Mention from Julian Elve on : ...I then found the approach documented by Mark Everitt which compares the RSS feed before and after the build and pushes webmentions for all new items, and have adapted his code.