在 embed.js 中暴露 external_id

我明白了。您想使用此处显示的脚本:https://meta.discourse.org/t/embed-discourse-comments-on-another-website-via-javascript/31963#alternate-configuration-linking-to-existing-topics-6。但您想使用 external_id 参数而不是 topicId 参数。

这也许可以作为一个功能添加。

也有可能在客户端发出请求,例如:
http://localhost:4200/t/external_id/1.json
然后从响应中提取帖子的实际 URL,并解析该 URL 以提取帖子的 id,或者向帖子的 URL 发出第二个请求以获取帖子 id。
这似乎很容易出错。

如果您在服务器端而不是客户端添加嵌入脚本,您可以直接向 http://localhost:4200/t/external_id/1.json 发出 GET 请求,执行任何您需要的操作以获取 Discourse 帖子的 id,然后使用该 id 将脚本插入到您的网页中。