mirror of
https://github.com/wassname/talk.git
synced 2026-07-02 15:40:56 +08:00
if the asset_url is not present, attempt to find the canonical link tag. if not, warn the user and strip the query params.
This commit is contained in:
@@ -167,7 +167,16 @@ Talk.render = function (el, opts) {
|
||||
el.id = `_${Math.random()}`;
|
||||
}
|
||||
|
||||
let asset_url = opts.asset_url || window.location.href.split('#')[0];
|
||||
let asset_url = opts.asset_url;
|
||||
if (!asset_url) {
|
||||
try {
|
||||
asset_url = document.querySelector('link[rel="canonical"]').href;
|
||||
} catch (e) {
|
||||
console.warn('This page does not include a canonical link tag. Talk has inferred this asset_url from the window object. Query params have been stripped, which may cause a single thread to be present across multiple pages.');
|
||||
asset_url = window.location.origin + window.location.pathname;
|
||||
}
|
||||
}
|
||||
|
||||
let comment = window.location.hash.slice(1);
|
||||
|
||||
let query = {
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@
|
||||
<script src="/embed.js" async onload="
|
||||
Coral.Talk.render(document.getElementById('coralStreamEmbed'), {
|
||||
talk: '/',
|
||||
asset: '<%= asset_url ? asset_url : '' %>'
|
||||
asset_url: '<%= asset_url ? asset_url : '' %>'
|
||||
})
|
||||
"></script>
|
||||
</main>
|
||||
|
||||
Reference in New Issue
Block a user