Package Exports
- webmen
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (webmen) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
webmen
A small module to send WebMentions. Should work in both Node and the browser, although you might want to include polyfills for Array.from, Promise and fetch for the latter.
This project also includes TypeScript type definitions.
Installation
npm install webmen --saveUsage
import { webmention } from 'webmen';
webmention('http://poop.bike', 'https://webmention.rocks/test/1')
.then((success) => console.log('Did the target at webmention.rocks accept the WebMention?', success))
.catch((error) => console.error('Something went wrong sending a WebMention:', error));Changelog
See CHANGELOG.md.
License
MIT © Vincent Tunru
API
Index
Functions
Functions
discover
▸ discover(target: string): Promise<string | null>
Defined in src/discover.ts:13
Given a target that is linked to, finds that page's associated WebMention endpoint, if any.
Parameters:
| Name | Type | Description |
|---|---|---|
target |
string | The web page that is mentioned. If the page supports WebMentions, it will include a reference to an endpoint (e.g. <link rel="webmention" href="https://endpoint.example">) that a WebMention should be sent to. |
Returns: Promise<string | null>
A Promise that is either rejected, e.g. when the network is down, or resolved. If it is resolved, it will either return the endpoint referred to in the target page, or null if it did not refer to an endpoint.
send
▸ send(endpoint: string, source: string, target: string): Promise<Response>
Defined in src/send.ts:12
Given an endpoint (see discover), send it a WebMention.
Parameters:
| Name | Type | Description |
|---|---|---|
endpoint |
string | An endpoint that is set up to receive WebMentions for a given target. |
source |
string | The page that links to target. |
target |
string | A page whose WebMention endpoint is endpoint, and which is linked to from source. |
Returns: Promise<Response>
webmention
▸ webmention(source: string, target: string): Promise<boolean>
Defined in index.ts:15
Notify target that source links to it. You will usually use this method.
This should be called when the link to target is added, and again every time source is updated, or if/when it eventually is deleted.
Parameters:
| Name | Type | Description |
|---|---|---|
source |
string | The web page that mentions target; it should actually include a link to target to be a valid WebMention, or have included one at some point of time in the past. |
target |
string | The web page that is mentioned by source. webmen will attempt to find a reference to the WebMention endpoint there, to which the actual WebMention will be sent. |
Returns: Promise<boolean>
A Promise that is either rejected, e.g. when the network is down, or resolved with either true (target accepted the WebMention) or false (e.g. target does not support WebMentions).