Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't get Schnack to work programmatically #86

Open
jfilter opened this issue Nov 30, 2018 · 5 comments
Open

I can't get Schnack to work programmatically #86

jfilter opened this issue Nov 30, 2018 · 5 comments

Comments

@jfilter
Copy link
Contributor

jfilter commented Nov 30, 2018

With this:

    <div class="comments-go-here"></div>

    <script src="https://schnack.exam.tld/client.js"></script>
    <script>
      new Schnack({
        target: ".comments-go-here",
        slug: "post-slug",
        host: "https://schnack.exam.tld"
      });
    </script>

I receive:

Uncaught (in promise) TypeError: Cannot read property 'SignInVia' of undefined

in the client. Embedding it directly in the HTML works though. Do you have any guesses what am I doing wrong?

@gka
Copy link
Member

gka commented Nov 30, 2018

shouldn't it be embed.js ?

@jfilter
Copy link
Contributor Author

jfilter commented Nov 30, 2018

If I replace https://schnack.exam.tld/client.js with https://schnack.exam.tld/embed.js I receive the following error:

schnack script tag needs some data attributes

@gka
Copy link
Member

gka commented Nov 30, 2018

ah I see. with the last version we added the localization feature.
this breaks your use case bc the default values are pre-filled in index.js, not in client.js.

you can copy them into your constructor for now: https://github.com/schn4ck/schnack/blob/master/src/embed/index.js#L11-L25

@jfilter
Copy link
Contributor Author

jfilter commented Dec 1, 2018

Thanks!

@leviwheatcroft
Copy link

Maybe obvious to everyone else but you need a partials property like this:

  new Schnack({
    target: '#comments-container',
    slug: $(this).data('slug'),
    host: 'https://comments.example.com',
    partials: {
      Preview: `Preview`,
      Edit: `Edit`,
      SendComment: `Send comment`,
      Cancel: `Cancel`,
      Or: ``,
      Mute: `mute notifications`,
      UnMute: `unmute`,
      PostComment: `Post a comment. Markdown is supported!`,
      AdminApproval: `This comment is still waiting for your approval`,
      WaitingForApproval: `Your comment is still waiting for approval by the site owner`,
      SignInVia: `To post a comment you need to sign in with one of these providers:`,
      Reply: `<i class='icon schnack-icon-reply'></i> reply`,
      LoginStatus: "(signed in as <span class='schnack-user'>@%USER%</span> :: <a class='schnack-signout' href='#'>sign out</a>)"
    }
  })

Took me a while to figure out why mine wasn't working :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants