Adding Utterances via custom component
See original GitHub issueI would like to add support for comments to my blog via Utterances.
I think the way I am supposed to do it is with a custom component.
Utterances is enabled on a particular page by adding the following HTML.
<script src="https://utteranc.es/client.js"
repo="[ENTER REPO HERE]"
issue-term="pathname"
theme="github-light"
crossorigin="anonymous"
async>
</script>
I think I have followed all the instructions for adding a custom component. My problem is that TypeScript doesn’t think repo
is a valid attribute of a script
element.
TSError: ⨯ Unable to compile TypeScript: .codedoc/components/utterances/index.tsx(11,18): error TS2322: Type ‘{ src: string; repo: string; “issue-term”: string; label: string; theme: string; crossorigin: string; async: true; }’ is not assignable to type ‘ScriptAttributes’. Property ‘repo’ does not exist on type ‘ScriptAttributes’.
Conceptually, I know that I want to add tell the TypeScript type system to allow these attributes for this tag, but I don’t know how to do that. I think it should be something similar to these top search results on SO, but I am not familiar enough with this to know how to apply these solutions for a site hosted by coding.blog
.
Here is the branch that contains my attempt to get this working.
How can I enable Utterances on a page of a site hosted by coding.blog
?
(My apologies if this is a standard tsx problem and the solution has nothing to do with coding.blog
.)
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (10 by maintainers)
Top GitHub Comments
It’s hard to detect this issue since there is a second argument being passed to the function, its just that the function (the component) expects a renderer while an options parameter is being passed:
As for documentation though, yes generally connective html and connective sdh are seriously lacking in documentation ATM.
Another potentially related issue.
When I try to pass in a theme like this…
…the comments don’t appear in dark mode. See my sample blog post 2.
P.S. I passed in
github-light
in both cases on purpose since I know that works for my sample blog post in both light and dark modes.