File size: 1,027 Bytes
96dd062
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
---
import { commentConfig } from "@/config";

interface Props {
	identifier: string;
	url: string;
	title: string;
}

const { identifier, url, title } = Astro.props;

if (!commentConfig || !commentConfig.disqus) {
	throw new Error("Disqus comments are not configured");
}
const shortname = commentConfig.disqus.shortname;
---

<div id="disqus_thread"></div>

<script is:inline define:vars={{ shortname, identifier, url, title }}>
  // @ts-ignore
  window.disqus_config = function () {
    this.page.url = url
    this.page.identifier = identifier
    this.page.title = title
  }

  ;(function () {
    var d = document,
      s = d.createElement('script')
    s.src = 'https://' + shortname + '.disqus.com/embed.js'
    s.setAttribute('data-timestamp', new Date().toString())
    ;(d.head || d.body).appendChild(s)
  })()
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<style is:global></style>