1

我在我的 MacOS 上安装了 ApostropheCMS 2 的副本,但我遇到了博客模块的情况。当我尝试编辑现有博客文章时,我看到“该项目不存在。”,但我可以在文章列表中看到它。

所以,这里是 app.js:

'apostrophe-blog': {
  widget: true,
  contextual: true 
},
'apostrophe-blog-pages': {},
'apostrophe-blog-widgets': {},

在'modules {'之前,我有:

 bundles: [ 'apostrophe-blog' ],

我的撇号-blog-page.html 包含:

 {% block main %}
  <div class="main-content">

        {{ apos.area(data.page, 'body', {
        widgets: {
            'apostrophe-blog': {}
        }
        }) }}

  </div>
{% endblock %}

现在:/blog 页面是空的,在文章列表中我可以看到所有文章,但是当我尝试编辑一次时,出现错误“该项目不存在”。

有什么解决办法吗?

4

1 回答 1

0

因此,我对这个问题做了一些深入的研究,它似乎与 Apostrophe 的先前版本或其中一个依赖项有关(我无法确定错误发生的确切位置)。

这是我们现在在隔离的 VM 中运行的 3 个不同的 Apostrophe 部署中看到的场景。

间歇性地,在一段未确定的时间后,撇号博客模块将停止在 Mongo 中新创建的文档中自动创建 publishedAt 属性。如果您正在挖掘数据作为参考,您可以使用以下查询在 aposDocs 集合中找到它们:

列出所有博客文章

db.getCollection('aposDocs').find({"type": "apostrophe-blog"})

列出所有缺少属性的博客文章

db.getCollection('aposDocs').find({"type": "apostrophe-blog", "publishedAt": {$exists : false}})

如果我们然后使用以下语句添加回属性,我们可以修复损坏的文章:

db.getCollection('aposDocs').update({"type": "apostrophe-blog", "publishedAt": {$exists : false}}, {$set: {"published": false, "publishedAt": ""}})

您的文章现在应该加载。下一步是防止这种情况再次发生。我们发现我们的安装已经过时了。您可以运行以下命令来确定是否需要更新:

npm outdated

这将吐出如下报告:

apostrophe         2.1.5  2.10.2  2.10.2  apostrophe

在我们的例子中,撇号已经过时了。然后我们通过以下方式更新:

npm update apostrophe

这将使您的安装保持最新。现在进行测试,我们看到已为数据库中的所有新撇号博客文档正确地自动创建了 publishedAt 属性。

于 2016-12-07T20:45:03.277 回答