aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--haunt/js/webmention.js33
1 files changed, 25 insertions, 8 deletions
diff --git a/haunt/js/webmention.js b/haunt/js/webmention.js
index 5986628..085f525 100644
--- a/haunt/js/webmention.js
+++ b/haunt/js/webmention.js
@@ -17,14 +17,24 @@
* <http://www.gnu.org/licenses/>.
*/
-// TODO: Page-specific comments.
-// TODO: Build up from aliases, etc.
-const REFURI = "jakob.space";
-const APIURI = [
- "https://webmention.io/api/mentions.jf2?",
- `target[]=http://${REFURI}&`,
- `&target[]=https://${REFURI}`
-].join("");
+function buildApiUri() {
+ const snip = /https?:\/\/.*?\//.exec(window.location.href);
+ const page = window.location.href.substring(snip[0].length);
+
+ // TODO: Build up from aliases, etc.
+ const aliases = [page];
+
+ return Array.concat(
+ ["https://webmention.io/api/mentions.jf2?"],
+ aliases.flatMap((alias) => {
+ const ref = "jakob.space";
+ return [
+ `target[]=http://${ref}/${alias}`,
+ `target[]=https://${ref}/${alias}`
+ ];
+ }).join("&")
+ ).join("");
+}
function getData(url, callback) {
if (fetch) {
@@ -121,3 +131,10 @@ function makeComment(comment) {
return wrapper;
}
+
+getData(buildApiUri(), (json) => {
+ json.children
+ .map(makeComment)
+ .forEach((elem) => {
+ document.getElementById("webmention-container").appendChild(elem);
+ })});

© 2015 - 2026 Jakob L. Kreuze