使用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"}
  ]
}

解决方法

我当前的方法是在视图本身中。我遍历fields.tags并在数组中搜索它们。我保存了索引并将其用于frontmatter.tags(它们的顺序很愉快)

正是该代码:

    DiscoveryDocumentResponse disco = 
    await client.GetDiscoveryDocumentAsync(new DiscoveryDocumentRequest { 
                    Address = "http://<identity-url>",Policy = { RequireHttps = false } 
                });

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...