【问题标题】:How to get Commento working in Gridsome Vue project?如何让 Commento 在 Gridsome Vue 项目中工作?
【发布时间】:2020-02-10 13:16:56
【问题描述】:

我建立了一个基于 Gridsome 的博客,现在我正在尝试将 cmets 添加到其中。我想避免使用 Disqus,所以我尝试使用 Commento。不幸的是,我似乎无法让它工作。我已将 ID 为 commento 的 div 添加到我的博客页面模板中:

<template>
<Layout :title="$page.blog.title">
    <Header :post="$page.blog" />
    <div class="g8-blog">
        <div class="g8-blog-content" v-html="$page.blog.content" />
        <div id="commento"></div>
    </div>
</Layout>
</template>

并将链接添加到我的元信息中。

metaInfo() {
    let blog = this.$page.blog;
    return {
        title: blog.title,
        link: [
            { src: 'https://cdn.commento.io/js/commento.js', defer: true }
        ]
    } 
}

当我检查页面代码时,它看起来还不错,但 Commento 评论的东西永远不会呈现。我还有什么需要做的吗?

【问题讨论】:

  • 呃,没关系,我不小心将我的更改提交到了错误的分支。以上工作。我会选择@HammerAn 的答案,因为它是准确的。

标签: vue.js gridsome


【解决方案1】:

这个对我有用:

<script>
  export default  {
    metaInfo() {
      return {
        title: this.$page.post.title,
        script: [
          { src: 'https://cdn.commento.io/js/commento.js', defer: true }
        ]
      };
    }
  };
</script>

【讨论】:

  • 嗯,这看起来和我做的一模一样。你可以添加模板的样子吗?谢谢!
猜你喜欢
  • 2019-08-14
  • 2020-03-13
  • 1970-01-01
  • 2022-01-01
  • 2019-03-13
  • 2018-03-21
  • 2021-09-27
  • 2017-11-03
  • 2020-12-10
相关资源
最近更新 更多