Graphql 向盖茨比进口中型商品

Graphql 向盖茨比进口中型商品,graphql,rss,gatsby,medium.com,gatsby-plugin,Graphql,Rss,Gatsby,Medium.com,Gatsby Plugin,我正在尝试将我的媒体提要集成到《盖茨比》中,只想选择几篇文章,而不是最新的。我能够使用此代码获得最近的三篇文章: index.config mediumRssFeed: "https://api.rss2json.com/v1/api.json?rss_url=https%3A%2F%2Fmedium.com%2Ffeed%2F%40maxgraze", shownArticles: 3, Articles.js const Articles = () =&g

我正在尝试将我的媒体提要集成到《盖茨比》中,只想选择几篇文章,而不是最新的。我能够使用此代码获得最近的三篇文章:

index.config

 mediumRssFeed:
    "https://api.rss2json.com/v1/api.json?rss_url=https%3A%2F%2Fmedium.com%2Ffeed%2F%40maxgraze",
  shownArticles: 3,
Articles.js

const Articles = () => {
  const MAX_ARTICLES = shownArticles

  const { isIntroDone, darkMode } = useContext(Context).state
  const [articles, setArticles] = useState()
  const articlesControls = useAnimation()

  // Load and display articles after the splashScreen sequence is done
  useEffect(() => {
    const loadArticles = async () => {
      if (isIntroDone) {
        await articlesControls.start({
          opacity: 1,
          y: 0,
          transition: { delay: 1 },
        })
        fetch(mediumRssFeed, { headers: { Accept: "application/json" } })
          .then(res => res.json())
          // Feed also contains comments, therefore we filter for articles only
          .then(data => data.items.filter(item => item.categories.length > 0))
          .then(newArticles => newArticles.slice(0, MAX_ARTICLES))
          .then(articles => setArticles(articles))
          .catch(error => console.log(error))
      }
    }
    loadArticles()
  }, [isIntroDone, articlesControls, MAX_ARTICLES])
但我希望使用盖茨比源媒体查询特定的文章。但是,它只返回4(甚至不返回最新的4)

有没有办法通过盖茨比源媒体获取我所有的文章?否则,有没有办法“硬编码”我想要的文章?我不知道如何使用rss提要api进行过滤。谢谢你的帮助


正如您所建议的,有一种更为自然的使用方法,但文档中缺少很好的示例

// In your gatsby-config.js
plugins: [
  {
    resolve: `gatsby-source-medium`,
    options: {
      username: `username/publication`,
    },
  },
]
更新:

这似乎是一个已知的中等来源的错误,我们对我们的项目无能为力。有关进一步详情:

类似以下的查询将收集预览图像中用户的所有帖子:

query {
  allMediumPost(sort: { fields: [createdAt], order: DESC }) {
    edges {
      node {
        id
        title
        virtuals {
          subtitle
          previewImage {
            imageId
          }
        }
        author {
          name
        }
      }
    }
  }
}

正如您所建议的,有一种更为自然的使用方法,但文档中缺少很好的示例

// In your gatsby-config.js
plugins: [
  {
    resolve: `gatsby-source-medium`,
    options: {
      username: `username/publication`,
    },
  },
]
更新:

这似乎是一个已知的中等来源的错误,我们对我们的项目无能为力。有关进一步详情:

类似以下的查询将收集预览图像中用户的所有帖子:

query {
  allMediumPost(sort: { fields: [createdAt], order: DESC }) {
    edges {
      node {
        id
        title
        virtuals {
          subtitle
          previewImage {
            imageId
          }
        }
        author {
          name
        }
      }
    }
  }
}

非常感谢你的帮助!你能给我举个例子,说明我会在“你的出版物”中写些什么吗?文章标题?我不太清楚那代表什么。再次感谢!为了澄清,我尝试指定我发布到的媒体博客,但没有运气(@maxgraze/nightingale),并且出现以下类型错误:“error-TypeError:无法读取未定义的属性‘references’。”您是否尝试了通过添加我列出的配置(@maxgraze/nightingale)在
localhost:8000/\uuuuuu graphql
中进行查询由于出现该错误,我无法运行该应用程序,因此无法使用您列出的查询。这似乎是一个众所周知的错误。非常感谢你的帮助!你能给我举个例子,说明我会在“你的出版物”中写些什么吗?文章标题?我不太清楚那代表什么。再次感谢!为了澄清,我尝试指定我发布到的媒体博客,但没有运气(@maxgraze/nightingale),并且出现以下类型错误:“error-TypeError:无法读取未定义的属性‘references’。”您是否尝试了通过添加我列出的配置(@maxgraze/nightingale)在
localhost:8000/\uuuuuu graphql
中进行查询由于出现该错误,我无法运行该应用程序,因此无法使用您列出的查询。这似乎是一个已知的错误