commento.js: add data-page-id option

This commit is contained in:
Adhityaa Chandrasekar 2019-12-05 20:02:19 -08:00
parent 2f9368a275
commit 0b1e2002d0

View File

@ -68,6 +68,7 @@
var origin = "[[[.Origin]]]"; var origin = "[[[.Origin]]]";
var cdn = "[[[.CdnPrefix]]]"; var cdn = "[[[.CdnPrefix]]]";
var root = null; var root = null;
var pageId = parent.location.pathname;
var cssOverride; var cssOverride;
var noFonts; var noFonts;
var hideDeleted; var hideDeleted;
@ -391,7 +392,7 @@
var json = { var json = {
"commenterToken": commenterTokenGet(), "commenterToken": commenterTokenGet(),
"domain": parent.location.host, "domain": parent.location.host,
"path": parent.location.pathname, "path": pageId,
}; };
post(origin + "/api/comment/list", json, function(resp) { post(origin + "/api/comment/list", json, function(resp) {
@ -718,7 +719,7 @@
var json = { var json = {
"commenterToken": commenterToken, "commenterToken": commenterToken,
"domain": parent.location.host, "domain": parent.location.host,
"path": parent.location.pathname, "path": pageId,
"parentHex": id, "parentHex": id,
"markdown": markdown, "markdown": markdown,
}; };
@ -1888,7 +1889,7 @@
var json = { var json = {
"commenterToken": commenterTokenGet(), "commenterToken": commenterTokenGet(),
"domain": parent.location.host, "domain": parent.location.host,
"path": parent.location.pathname, "path": pageId,
"attributes": attributes, "attributes": attributes,
}; };
@ -2038,6 +2039,11 @@
var scripts = tags("script") var scripts = tags("script")
for (var i = 0; i < scripts.length; i++) { for (var i = 0; i < scripts.length; i++) {
if (scripts[i].src.match(/\/js\/commento\.js$/)) { if (scripts[i].src.match(/\/js\/commento\.js$/)) {
var pid = attrGet(scripts[i], "data-page-id");
if (pid !== undefined) {
pageId = pid;
}
cssOverride = attrGet(scripts[i], "data-css-override"); cssOverride = attrGet(scripts[i], "data-css-override");
autoInit = attrGet(scripts[i], "data-auto-init"); autoInit = attrGet(scripts[i], "data-auto-init");