Javascript 如何使用gatsby中的引文.js将bibtext条目呈现到HTML参考书目中?

Javascript 如何使用gatsby中的引文.js将bibtext条目呈现到HTML参考书目中?,javascript,reactjs,prototype,gatsby,citations,Javascript,Reactjs,Prototype,Gatsby,Citations,我正在尝试将bibtext条目呈现到格式化的APA样式的HTML书目中,所有内容都可以在我的new Cite()的第一个实例中正常工作,但是我的第二个实例输出了第一个实例的结果:| 我使用的是Gatby.js,因此我将引文.js脚本作为带有react helmet的标记加载,并在componentDidMount()中使用库 问题是: componentDidMount() { const Cite = require('citation-js') // creat

我正在尝试将bibtext条目呈现到格式化的APA样式的HTML书目中,所有内容都可以在我的
new Cite()
的第一个实例中正常工作,但是我的第二个实例输出了第一个实例的结果:|

我使用的是Gatby.js,因此我将引文.js脚本作为带有react helmet的标记加载,并在componentDidMount()中使用库

问题是:


  componentDidMount() {  

    const Cite = require('citation-js')

    // create an instance of Cite
    const Cite1 = new Cite();

    // add the first bibtext entry
    Cite1.add(bibtext1);

    // create a bibliography
    const formatted1 = Cite1.format('bibliography', {
      format: 'html',
      template: 'apa'
    })

    // everything is great!!!
    console.log(Cite1); // output a Cite object with data from bibtext1 
    console.log(formatted1);// output a html block with data from bibtext1 



    // Same process here but with the second entry
    const Cite2 = new Cite();

    // this successfully add the second entry to the second Cite object
    Cite2.add(bibtext2);

    // create a second bibliography
    const formatted2 = Cite2.format('bibliography', {
      format: 'html',
      template: 'apa'
    })  

    console.log(Cite2);   // this output a Cite object with data from bibtext2 which is great,

    console.log(formatted2);  // But this output a html block with the data from bibtext1 
    //even though I used Cite2 which was a new instance of Cite with a different bibtext entry, why????

}

您好,我是引文.js包的作者。我看不到同样的事情,但我能想到这样的错误会发生的原因。您使用的是什么版本的引文.js?(引用版本的输出)Hi@LarsW!我正在使用
{引用:“0.5.0-alpha.4”,citeproc:“1.2.32”}
我更改了
npm I引用的npm包-js@0.4.9
Cite.version
现在输出
{Cite:“0.4.9”,citeproc:“1.2.32”}
但我仍然有双重输出。嗨@LarsW,知道为什么会发生这种情况吗?我看到npm上有一个新版本
0.5.0-alpha.5
我试过了,它似乎引起了同样的问题。
0.5.0-alpha.5
只是我之前忘记发布的版本。这个问题很可能是由Quiction.js试图缓存的处理引擎实例引起的,我现在确实看到了一个问题,如果您使用具有相同ID但不同数据的项创建一个新的引用实例,它会显示第一个实例。我会解决这个问题,但这真的是你数据中的问题吗?嗨,我是引文.js包的作者。我看不到同样的事情,但我能想到这样的错误会发生的原因。您使用的是什么版本的引文.js?(引用版本的输出)Hi@LarsW!我正在使用
{引用:“0.5.0-alpha.4”,citeproc:“1.2.32”}
我更改了
npm I引用的npm包-js@0.4.9
Cite.version
现在输出
{Cite:“0.4.9”,citeproc:“1.2.32”}
但我仍然有双重输出。嗨@LarsW,知道为什么会发生这种情况吗?我看到npm上有一个新版本
0.5.0-alpha.5
我试过了,它似乎引起了同样的问题。
0.5.0-alpha.5
只是我之前忘记发布的版本。这个问题很可能是由Quiction.js试图缓存的处理引擎实例引起的,我现在确实看到了一个问题,如果您使用具有相同ID但不同数据的项创建一个新的引用实例,它会显示第一个实例。我会解决这个问题,但这真的是数据中的问题吗?