We end up passing the same discourseUrl which is the instance of discourse. Then we pass either a discourseEmbedUrl or a topicId along depending on which section of the site the comments will be going in. The topic id is added to the dom during page render if it already exists.
Here is a code snippet
var TOPIC_ID_ATTR = 'data-discourse-topic-id';
var shareUrl = $('meta[property="og:url"]').attr('content'),
topicId = $('[' + TOPIC_ID_ATTR + ']');
var embedConfig = {
discourseUrl: <forumUrl>
};
if (topicId.length > 0) {
embedConfig.topicId = parseInt(topicId.attr(TOPIC_ID_ATTR));
}
else {
embedConfig.discourseEmbedUrl = shareUrl;
}
window.DiscourseEmbed = embedConfig;