psychobunny / nodebb-plugin-blog-comments

Lets NodeBB act as a comments engine/widget for your blog
BSD 2-Clause "Simplified" License
99 stars 55 forks source link

'untitled' when creating articles via script #75

Open ComputerCarl opened 6 years ago

ComputerCarl commented 6 years ago

I am using the following in React to use NodeBB as comments. While the articles are created, the title of all is undefined. What are the proper variables to set to make this work properly?

function loadScript(src) {
  return new Promise(function (resolve, reject) {
    var s;
    s = document.createElement('script');
    s.src = src;
    s.onload = resolve(s);
    s.onerror = reject;
    document.head.appendChild(s);
  });
}

  componentDidMount() {
    const { articleID } = this.props;

    var nodeBBURL = 'https://mysite.xyz';
    let obj = {
      title_plain: 'this is page 2',
      url: 'http://mysite.xyz',
      tags: ['awesome'],
      markDownContent: 'Sometimes life can be **bold**.',
      cid: 5
    }
    window.articleID = articleID;
    // articleData is not being used; site title is `undefined`, no tags
    window.articleData = JSON.stringify(obj);
    window.nodeBBURL = nodeBBURL;
    loadScript(nodeBBURL + '/plugins/nodebb-plugin-blog-comments/lib/general.js')
  }
ComputerCarl commented 6 years ago

Perhaps I should be using nodebb-plugin-write-api instead?