Merge branch 'master' of github.com:umputun/remark

This commit is contained in:
Umputun
2018-03-11 13:52:13 -05:00
5 changed files with 16 additions and 9 deletions
+4 -1
View File
@@ -12,7 +12,10 @@ export const find = ({ url }) => fetcher.get(`/find?url=${url}&sort=-score&forma
export const last = ({ siteId, max }) => fetcher.get(`/last/${max}?site=${siteId}`);
export const count = ({ url, siteId }) => fetcher.get(`/count?url=${url}&site=${siteId}`);
export const count = ({ urls, siteId }) => fetcher.post({
url: `/count?site=${siteId}`,
body: urls,
});
export const getComment = ({ id }) => fetcher.get(`/id/${id}?url=${url}`);
@@ -1,4 +1,3 @@
.list-comments {
position: relative;
font-family: 'PT Sans', Helvetica, Arial, sans-serif;
}
+10 -6
View File
@@ -9,7 +9,7 @@ if (document.readyState !== 'interactive') {
}
function init() {
const nodes = document.getElementsByClassName(COUNTER_NODE_CLASSNAME);
const nodes = [].slice.call(document.getElementsByClassName(COUNTER_NODE_CLASSNAME));
if (!nodes) {
console.error('Remark42: Can\'t find counter nodes.');
@@ -28,10 +28,14 @@ function init() {
return;
}
[].slice.call(nodes).forEach(node => {
const url = node.dataset.url || remark_config.url || window.location.href;
api.count({ url, siteId: remark_config.site_id })
.then(({ count }) => { node.innerHTML = count; });
});
const map = nodes.reduce((acc, node) => {
acc[node.dataset.url || remark_config.url || window.location.href] = node;
return acc;
}, {});
api.count({ urls: Object.keys(map), siteId: remark_config.site_id })
.then(res => {
res.forEach(item => (map[item.url].innerHTML = item.count));
});
}
+1
View File
@@ -3,6 +3,7 @@ import 'common/polyfills'; // TODO: check it
import { h, render } from 'preact';
import Root from './components/root';
import ListComments from './components/list-comments'; // TODO: temp solution for extracting styles
import { NODE_ID } from './common/constants';
+1 -1
View File
@@ -38,10 +38,10 @@ const commonStyleLoaders = [
module.exports = {
context: __dirname,
entry: {
remark: './app/remark',
embed: './app/embed',
counter: './app/counter',
'last-comments': './app/last-comments',
remark: './app/remark',
},
output: {
path: publicFolder,