Skip to content

Commit 11ceb7a

Browse files
committed
feat(component:disqus): add component Disqus
1 parent ce837a7 commit 11ceb7a

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/components/Disqus.astro

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
interface Props {
3+
siteId: string
4+
pageURL: string
5+
pageIdentifier: string
6+
}
7+
8+
const { siteId, pageURL, pageIdentifier } = Astro.props
9+
---
10+
11+
<div id="disqus_thread"></div>
12+
<script define:vars={{ siteId, pageURL, pageIdentifier }}>
13+
var disqus_config = function () {
14+
this.page.url = pageURL
15+
this.page.identifier = pageIdentifier
16+
}
17+
;(function () {
18+
// DON'T EDIT BELOW THIS LINE
19+
var d = document,
20+
s = d.createElement('script')
21+
s.src = `https://${siteId}.disqus.com/embed.js`
22+
s.setAttribute('data-timestamp', new Date().toString())
23+
;(d.head || d.body).appendChild(s)
24+
})()
25+
</script>
26+
<noscript>
27+
Please enable JavaScript to view the
28+
<a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a>
29+
</noscript>

src/configs/site.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,8 @@ export default {
4949
swetrix: {
5050
projectId: env.SWETRIX_ID,
5151
},
52+
disqus: {
53+
siteId: env.DISQUS_ID,
54+
},
5255
}
5356
}

0 commit comments

Comments
 (0)