Migration to @waline/client V2
API changes
We removed Waline's default export and instead provide the following exports:
init: behave like the oldWalineversion: version numbercommentCount: number of updated commentspageviewCount: update the number of visitsRecentComments: recent comments
We changed Waline's default export to init named export, and to make Waline SSR friendly, V2 exports CSS separately.
In most cases, this just means the following changes:
- <script src='//cdn.jsdelivr.net/npm/@waline/client'></script>
+ <script src='//unpkg.com/@waline/client@v2/dist/waline.js'></script>
+ <link href='//unpkg.com/@waline/client@v2/dist/waline.css' rel='stylesheet' />
<script>
- Waline({
+ Waline.init({
el: '#waline',
serverURL: 'YOUR SERVER URL'
});
</script>
Options Added
- The
commentoption supports setting strings as CSS selectors. - The
pageviewoption supports setting strings as CSS selectors.
Options Renamed
uploadImagerenamed toimageUploaderhighlightrenamed tohighlighterpreviewMathrenamed totexRenderervisitorrenamed topageview
Options Removed
The following options have long been marked as deprecated APIs in V1, they have been removed in V2.
langMode: uselocalesplaceholder: uselocales.placeholderemojiCDN: useemojiemojiMaps: useemojirequiredFields: userequiredMetaavatar: use server variableAVATAR_PROXYavatarCDN: use server variableAVATAR_PROXYavatarForce: refresh by defaultanonymous: useloginmathTagSupport: usetexRenderercopyRight: usecopyright
Other changes
Instance
Waline.init now throws an error when the two required properties el, serverURL are invalid, instead of returning an error instance with reason.
You can use try { ... } catch (err) { ... } blocks to catch errors for better compatibility in case that user sets invalid options.
Update behavior changes
- Waline now supports updating all options except the
eloption viaInstance.update. pathparameter will reset onupdate(), which means as long as you don't passpathoptions duringupdate(), it will bewindow.location.pathname.
Comments and Pageview Selector Changes
Comments and views on Valine's selector compatibility have now been removed.
- The comment selector defaults to
'.waline-comment-count' - The pageview selector defaults to
'.waline-pageview-count'
If you need to get a different value for a selector than the current page, it is strongly recommended to use the data-path attribute.
For compatibility, we still keep the previous id attribute support, but this compatibility will be removed in V3.
CSS class changes
All CSS classes changed from v to wl-.






