feat(widget): 添加 postSlug 配置以支持多语言/多路径评论聚合

- 在配置面板和核心逻辑中新增 postSlug 字段,允许自定义评论标识符
- 更新前端配置文档,说明 postSlug 的用途和默认行为
- 当未配置 postSlug 时,默认仍使用 window.location.pathname
This commit is contained in:
anghunk
2026-02-09 17:23:21 +08:00
parent cf068a6dc1
commit 6d2e1659d0
4 changed files with 36 additions and 16 deletions

View File

@@ -32,7 +32,7 @@ export class CWDComments {
if (config.siteId) {
this.config.siteId = config.siteId;
}
if (typeof window !== 'undefined') {
if (typeof window !== 'undefined' && !this.config.postSlug) {
this.config.postSlug = window.location.pathname;
}
if (typeof document !== 'undefined') {
@@ -577,7 +577,7 @@ export class CWDComments {
if (newConfig.siteId !== undefined) {
this.config.siteId = newConfig.siteId;
}
if (typeof window !== 'undefined') {
if (typeof window !== 'undefined' && !this.config.postSlug) {
this.config.postSlug = window.location.pathname;
}
if (typeof document !== 'undefined') {