使用gatsby-plugin-categories / gatsby-plugin-tags标记云和类别列表

问题描述

我想创建标签云(或类别列表),该标签云应链接到相应的标签文章和类别。但是在我构建的查询中,仅将nameslug连接在一起,因为它们放置在fieldsfrontmatter中,而不是放置在一个对象中

我使用这两个广泛使用的插件:https://github.com/rmcfadzean/gatsby-pantry

这是我当前的查询:

{
  tags: allMarkdownRemark(filter: {frontmatter: {title: {ne: ""}}}) {
    group(field: frontmatter___tags) {
      fieldValue
      totalCount
      edges {
        node {
          fields {
            tags
          }
          frontmatter {
            tags
          }
        }
      }
    }
  }
}

{
  "data": {
    "allMarkdownRemark": {
      "group": [
        {
          "fieldValue": "Another tag","totalCount": 1,"edges": [
            {
              "node": {
                "fields": {
                  "tags": [
                    "another-tag","my-example","post"
                  ]
                },"frontmatter": {
                  "tags": [
                    "Another tag","My example","Post"
                  ]
                }
              }
            }
          ]
        },{
          "fieldValue": "Example","edges": [
            {
              "node": {
                "fields": {
                  "tags": [
                    "example","frontmatter": {
                  "tags": [
                    "Example",{
          "fieldValue": "My example",{
          "fieldValue": "Post","totalCount": 2,"Post"
                  ]
                }
              }
            },{
              "node": {
                "fields": {
                  "tags": [
                    "example","Post"
                  ]
                }
              }
            }
          ]
        }
      ]
    }
  },}

如何获取类似这样的对象:

{ "tags": 
  [
   { "slug": "another-tag","frontmatter": "Another Tag"},{ "slug": "example","frontmatter": "Example"}
  ]
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)