Files
remark42/site/content/docs/configuration/frontend/_index.md
T
Dmitry VerkhoturovandGitHub a5b2fe3cfc Consolidate the frontend toolchain onto babel, and ship one bundle (#2178)
Four upgrades that were finished but never merged, the compiler collapse
they enable, and the dependency sweep that follows. Direct
devDependencies go from 78 to 60 and dependencies from 10 to 9.

Three were doing the same job: `ts-loader` stripped types in webpack,
`babel-loader` did everything else, and `@swc/jest` repeated both for the
tests with its own copy of the JSX settings. Babel is the one that
survives, because the `data-testid` stripper has no equivalent elsewhere.

`ts-loader` ran `transpileOnly: true`, so it only stripped types, which
`@babel/preset-typescript` does; `fork-ts-checker-webpack-plugin` was
already what type-checks. Jest runs `babel-jest` against the same
`.babelrc.js` the bundle uses, passed as `configFile` because a
file-relative babel config does not reach the `node_modules` packages in
`transformIgnorePatterns`, and `jest.config.mjs` is plain ESM because a
`.ts` config is compiled against `tsconfig.json`, whose
`verbatimModuleSyntax` rejects ESM syntax in a file the package has not
declared as a module.

That removes `ts-loader`, `@swc/jest` and `@swc/core`. The last was
pinned to 1.2.205 from 2022 with no way forward, because newer builds
emit non-configurable exports and break `jest.spyOn` across 13 suites.

Babel compiles a file at a time with no type information, so it cannot
tell a type-only import from a real one and keeps the module. One line,
`import { boundActions } from './connected-comment'`, pulled the whole
redux store into `last-comments.mjs` and doubled it. `verbatimModuleSyntax`
and `@typescript-eslint/consistent-type-imports` mark them properly; the
statement has to be a separate `import type`, since verbatim semantics
keep an inline `import { type X }` and load the module anyway.

The legacy and modern compilations produced the same bytes. Both read the
same browserslist query, `defaults, not IE 11, not samsung 12` resolves to
chrome 109 and up, and nothing in the source needs transforming for that
set, so 28 of the 29 output pairs were byte-identical.

That made the module/nomodule switch worse than redundant: it served the
`.js` file to browsers with no ES module support, and those files carried
`??`, `?.` and class fields, so the fallback handed its own audience a
syntax error. There is now one bundle, always loaded as a module, in the
five templates and in the seven `site/` documents integrators copy from.
A production build emits 29 files rather than 58, in about 3 seconds
rather than 17. Two of those documents did not work at all beforehand:
the SPA snippet could not parse, and the subdomain example had an
unterminated string.

`@babel/core` 8 declares `^22.18 || >=24.11` and `size-limit` 13 declares
`^22.18 || ^24 || >=26`, so 20 was below the floor of two things installed
here; pnpm only warns, which is why every build passed. All seven places
the frontend pins it move together. `site/` is untouched: it builds with
yarn and eleventy and installs neither.

`eslint --print-config` before and after gives 173 active rules on an
application file against 172, and 172 on a spec file and a plain JS file
against 171. What is gone is three `flowtype` rules with no Flow here,
`no-new-object` and `no-new-symbol` whose upstream replacements are on,
`react/forbid-foreign-prop-types` with no propTypes anywhere, and, on TS
only, `no-useless-constructor`, whose typescript-eslint version is on at
error. `@babel/core` is pinned to 8 across the workspace because
`@jest/transform` and `istanbul-lib-instrument` depend on 7 outright; a
second scoped override holds `eslint-config-preact` on 7, since its
`@babel/eslint-parser` loads babel 7 syntax plugins.

`fast-async` rewrote every async function into nodent promise chains,
calls babel's `transform` synchronously, which babel 8 removed, and every
browser in the target list runs async natively. `prefresh` blew its stack
on `createContext` under babel 8 with no newer release to move to, which
compiled `intl.tsx` and `store/context.tsx` into throwing stubs, so
`pnpm dev:app` could not run the widget at all. `core-js` is not injected
now that `useBuiltIns` is gone, `postcss-custom-properties` was reached
directly although nothing declared it and resolved only through pnpm's
private hoist directory, and `cssnano` ran in both postcss chains although
`CssMinimizerPlugin` already uses it.

`pnpm lint`, `pnpm test` and `pnpm build` now work from `frontend/` as
`CLAUDE.md` and the contributing guide have always said they do; the
workspace root defined none of them.
2026-08-21 19:13:25 -05:00

6.9 KiB
Raw Blame History

title, aliases
title aliases
Frontend Configuration
/docs/configuration/

Configuration

  • host: string (required) hostname of Remark42 server, same as REMARK_URL in backend config, e.g. "https://demo.remark42.com"
  • site_id: string (optional, remark by default) the SITE that you passed to Remark42 instance on start of backend.
  • url: string (optional, window.location.origin + window.location.pathname by default) url to the page with comments, it is used as unique identificator for comments thread Note that if you use query parameters as significant part of URL (the one that actually changes content on page) you will have to configure URL manually to keep query params, as window.location.origin + window.location.pathname doesn't contain query params and hash. For example, default URL for https://example/com/example-post?id=1#hash would be https://example/com/example-post
  • components: ['embed' | 'last-comments' | 'counter'] (optional, ['embed'] by default) an array of widgets that should be rendered on a page. You may use more than one widget on a page. Available components are:
    • 'embed' basic comments widget
    • 'last-comments' last comments widget, see Last Comments section below
    • 'counter' counter widget, see Counter section below
  • max_shown_comments: number (optional, 15 by default) maximum number of comments that is rendered on mobile version
  • max_last_comments: number (optional, 15 by default) maximum number of comments in the last comments widget
  • theme: 'light' | 'dark' (optional, 'light' by default) changes UI theme
  • page_title: string (optional, document.title by default) title for current comments page
  • locale: enum (optional, 'en' by default) interface localization, check possible localizations
  • show_email_subscription: boolean (optional, true by default) enables email subscription feature in interface when enable it from backend side, if you set this param in false you will get notifications email notifications as admin but your users won't have interface for subscription
  • show_rss_subscription: boolean (optional, true by default) enables RSS subscription feature in interface
  • simple_view: boolean (optional, false by default) overrides the parameter from the backend minimized UI with basic info only
  • no_footer: boolean (optional, false by default) hides footer with signature and links to Remark42

Example with all of the params:

<script>
	var remark_config = {
		host: 'https://remark42.example.com',
		site_id: 'my_site',
		components: ['embed', 'last-comments'],
		max_shown_comments: 100,
		theme: 'dark',
		page_title: 'My custom title for a page',
		locale: 'es',
		show_email_subscription: false,
		simple_view: true,
		no_footer: false
	}
</script>

Basic configuration

Place configuration on a page of your site. Add following initialization script after it.

<script>!function(e,n){for(var o=0;o<e.length;o++){var r=n.createElement("script"),d=n.head||n.body;r.type="module",r.async=!0,r.defer=!0,r.src=remark_config.host+"/web/"+e[o]+".mjs",d.appendChild(r)}}(remark_config.components||["embed"],document);</script>

Comments

It's the main widget that renders a list of comments with ability of commenting. Add following snippet in the place where you want to see Remark42 widget. The comments widget will be rendered in that place.

<div id="remark42"></div>

{{< note "💡" >}} Note: The initialization script should be placed after the code mentioned above. {{< /note >}}

You can place any placeholder content inside the remark42 div — it will be automatically removed once the comments widget has loaded. This is useful for showing a loading indicator or message while the widget initialises:

<div id="remark42">Comments loading...</div>

If you want to set this up on a Single Page App, see the appropriate doc page.

Themes

Remark42 has two themes: light and dark. You can pick one using a configuration object, but there is also a possibility to switch between themes in runtime. For this purpose, Remark42 adds to the window object named REMARK42, which contains a function changeTheme. Just call this function and pass a name of the theme that you want to turn on:

window.REMARK42.changeTheme("light")

Locales

Right now Remark42 is translated to English (en), Belarusian (be), Brazilian Portuguese (bp), Bulgarian (bg), Chinese (zh), Finnish (fi), French (fr), German (de), Japanese (ja), Korean (ko), Polish (pl), Russian (ru), Spanish (es), Turkish (tr), Ukrainian (ua), Italian (it) and Vietnamese (vi) languages. You can pick one using a configuration object.

Do you want to translate Remark42 to other locales? Please see this documentation for details.

Widgets

Last comments widget

It's a widget that renders the list of last comments from your site.

Add this snippet to the bottom of web page, or adjust already present remark_config to have last-comments in components list:

<script>
	var remark_config = {
		host: "REMARK_URL",
		site_id: "YOUR_SITE_ID",
		components: ["last-comments"],
	}
</script>

{{< note "💡" >}} Note: If you want to render not only last comments widget you need to add all of the names of widget that you want to initialize. {{< /note >}}

And then add this node in the place where you want to see last comments widget:

<div class="remark42__last-comments" data-max="50"></div>

data-max sets the max amount of comments (default: 15).

Counter widget

It's a widget that renders several comments for the specified page. Add this snippet to the bottom of web page, or adjust already present remark_config to have counter in components list:

<script>
	var remark_config = {
		host: "REMARK_URL",
		site_id: "YOUR_SITE_ID",
		components: ["counter"],
	}
</script>

{{< note "💡" >}} Note: If you want to render not only comments widget you need to add all of the names of widget that you want to initialize. {{< /note >}}

And then add a node like this in the place where you want to see a number of comments:

<span
	class="remark42__counter"
	data-url="https://domain.com/path/to/article/"
></span>

You can use as many nodes like this as you need to. The script will find all of them by the class remark__counter, and it will use the data-url attribute to define the page with comments.

Also, the script can use url property from remark_config object or window.location.origin + window.location.pathname if nothing else is defined.