diff --git a/README.md b/README.md
index 378a68e1..237edd29 100644
--- a/README.md
+++ b/README.md
@@ -308,18 +308,28 @@ Add this snippet to the bottom of web page:
```html
```
@@ -348,19 +358,24 @@ window.REMARK42.changeTheme('light');
It's a widget which renders list of last comments from your site.
-Add this snippet to the bottom of web page:
+Add this snippet to the bottom of web page, or adjust already present `remark_config` to have `last-comments` in `components` list:
```html
```
@@ -376,19 +391,24 @@ And then add this node in the place where you want to see last comments widget:
It's a widget which renders a number of comments for the specified page.
-Add this snippet to the bottom of web page:
+Add this snippet to the bottom of web page, or adjust already present `remark_config` to have `counter` in `components` list:
```html
```
diff --git a/frontend/app/common/closest-polyfill.js b/frontend/app/common/closest-polyfill.js
deleted file mode 100644
index d83819b2..00000000
--- a/frontend/app/common/closest-polyfill.js
+++ /dev/null
@@ -1,15 +0,0 @@
-if (!Element.prototype.matches) {
- Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
-}
-
-if (!Element.prototype.closest) {
- Element.prototype.closest = function(s) {
- let el = this;
-
- do {
- if (el.matches(s)) return el;
- el = el.parentElement || el.parentNode;
- } while (el !== null && el.nodeType === 1);
- return null;
- };
-}
diff --git a/frontend/app/common/closest-polyfill.ts b/frontend/app/common/closest-polyfill.ts
new file mode 100644
index 00000000..1fe57b04
--- /dev/null
+++ b/frontend/app/common/closest-polyfill.ts
@@ -0,0 +1,17 @@
+if (!Element.prototype.matches) {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ Element.prototype.matches = (Element.prototype as any).msMatchesSelector || Element.prototype.webkitMatchesSelector;
+}
+
+if (!Element.prototype.closest) {
+ Element.prototype.closest = function(s: string) {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ let el: any = this;
+
+ do {
+ if (el.matches(s)) return el;
+ el = el.parentElement || el.parentNode;
+ } while (el !== null && el.nodeType === 1);
+ return null;
+ };
+}
diff --git a/frontend/app/common/config-types.ts b/frontend/app/common/config-types.ts
index df727d3a..369e5db2 100644
--- a/frontend/app/common/config-types.ts
+++ b/frontend/app/common/config-types.ts
@@ -1,6 +1,7 @@
import { UserInfo, Theme } from './types';
export interface CounterConfig {
+ host: string;
site_id: string;
url?: string;
}
@@ -8,6 +9,7 @@ export interface CounterConfig {
export type UserInfoConfig = UserInfo;
export interface CommentsConfig {
+ host: string;
site_id: string;
url?: string;
max_shown_comments?: number;
@@ -16,6 +18,7 @@ export interface CommentsConfig {
}
export interface LastCommentsConfig {
+ host: string;
site_id: string;
max_last_comments: number;
}
diff --git a/frontend/app/common/constants.ts b/frontend/app/common/constants.ts
index 014f59cb..e95482f7 100644
--- a/frontend/app/common/constants.ts
+++ b/frontend/app/common/constants.ts
@@ -1,6 +1,8 @@
import { Sorting, AuthProvider, BlockingDuration, Theme } from './types';
-export const BASE_URL: string = process.env.REMARK_URL!;
+export const BASE_URL: string =
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ ((window as any).remark_config && (window as any).remark_config.host) || process.env.REMARK_URL!;
export const API_BASE = '/api/v1';
export const NODE_ID: string = process.env.REMARK_NODE!;
export const COUNTER_NODE_CLASSNAME = 'remark42__counter';
diff --git a/frontend/app/embed.ts b/frontend/app/embed.ts
index 538dc267..f86e6397 100644
--- a/frontend/app/embed.ts
+++ b/frontend/app/embed.ts
@@ -7,6 +7,8 @@ import { BASE_URL, NODE_ID, COMMENT_NODE_CLASSNAME_PREFIX } from '@app/common/co
import { UserInfo, Theme } from '@app/common/types';
import { CommentsConfig } from '@app/common/config-types';
+const HOST = remark_config.host || BASE_URL;
+
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
@@ -14,7 +16,7 @@ if (document.readyState === 'loading') {
}
async function init(): Promise {
- __webpack_public_path__ = BASE_URL + '/web/';
+ __webpack_public_path__ = HOST + '/web/';
await loadPolyfills();
const node = document.getElementById(NODE_ID);
@@ -47,7 +49,7 @@ async function init(): Promise {
node.innerHTML = `