question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding Utterances via custom component

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
loreanvictorcommented, Jun 23, 2020

Maybe the documentation about custom components could state that this argument is required (and maybe even give the error message that will occur is this rule is not followed). It could also recommended the idea of using _: any if the argument is not needed.

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:

  • To catch this error on compile time, you would basically need to do typechecking on markdown files,
  • Only way to detect it on runtime is to run a check inside the component function at the beginning, which would defeat the purpose since the burden would fall upon the developer writing the component function.

As for documentation though, yes generally connective html and connective sdh are seriously lacking in documentation ATM.

1reaction
TysonMNcommented, Jun 23, 2020

Another potentially related issue.

When I try to pass in a theme like this…

> :DarkLight
> > :InLight
> >
> > > :Utterances theme=github-light
>
> > :InDark
> >
> > > :Utterances theme=github-light

…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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create Intents, Utterances, and Slots | Alexa Skills Kit
When you create a new custom intent, you provide a name and a list of utterances that users would say to invoke this...
Read more >
example for react use · Issue #161 · utterance ... - GitHub
Just want to contribute this example made with JSX (react) cause it took me some time especially with the custom attributes for script...
Read more >
Use Input Recommender to Generate Utterances (Beta)
Use recommendations within new or existing dialog intents to build realistic training data based on phrases your customers already use in chat conversatio....
Read more >
The Custom Component Payload - Oracle Help Center
The response payload for the GET endpoint is made up of properties that are required to call the component along with the name...
Read more >
Building a Custom Component with the Oracle Digital Assistant
The simplest way to deploy a custom component is via an embedded container ... TestCustomComponent and add utterances (very original I know).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found