在即时文章的内容中添加相关文章FB的内容



我需要在即时文章的内容中添加一些相关帖子。我使用此WordPress插件:

https://github.com/automattic/facebook-instant-articles-wp

我的帖子有:

<ul class="related-article">
  <li>
     <a href="http://example.com/"></a>
  </li>
</ul>

我将其添加到我的变压器规则

{
      "class": "RelatedArticlesRule",
      "selector": ".related-article"
},
{
      "class": "RelatedItemRule",
      "selector": ".related-article li",
      "properties": {
        "related.url": {
          "type": "string",
          "selector": "a",
          "attribute": "href"
        }
      }
}

但是在trasformer标记中,相关的UL不存在。我需要这样的东西:

<ul class="op-related-article">
  <li>
     <a href="http://example.com/"></a>
  </li>
</ul>

看起来相关文章项目仅在RelatedArticlesRule内检查,因此您的选择器是错误的。

这应该有效:

{
  "class": "RelatedArticlesRule",
  "selector": "ul.related-article",
  "properties" : {
    "related.title" : {
        "type" : "string",
        "selector" : "ul.related-article",
        "attribute": "title"
     }
  }
},
{
  "class": "RelatedItemRule",
  "selector": "li",
  "properties": {
    "related.url": {
      "type": "string",
      "selector": "a",
      "attribute": "href"
    }
  }
}

相关内容

  • 没有找到相关文章

最新更新