【发布时间】:2021-02-14 00:49:56
【问题描述】:
所有文件查询:
query{
allFile{
edges{
node{
childMarkdownRemark{
frontmatter{
title
desc
link
}
}
childImageSharp{
fluid{
srcSetWebp
}
}
}
}
}
}
对于上述所有文件查询,我得到以下输出
{
"data": {
"allFile": {
"edges": [
{
"node": {
"childMarkdownRemark": {
"frontmatter": {
"title": "Arrays in Javascript ",
"desc": "I am hello i am the greatest lorem ipsum diut shit in the world of world",
"link": null
}
},
"childImageSharp": null
}
},
}
allMarkdown 查询:
query{
allMarkdownRemark{
edges{
node{
frontmatter{
title
desc
link
}
}
}
}
}
上述allMarkdown查询的输出是
{
"data": {
"allMarkdownRemark": {
"edges": [
{
"node": {
"frontmatter": {
"title": "This is party react",
"desc": "I am React GUyyyy ",
"link": null
}
}
},
输出限制为 1 项以节省问题的空间
allFile 和 allMarkdownRemark 查询之间是否存在性能差异
在allFile查询中,我们可以获取相对路径,相对目录,而allMarkdownRemark仅限于fileAbsolutePath
我们可以使用 childMarkdownRemark 在 allFile 查询中访问 markdown,如上所示。
在许多 YouTube 教程中,人们使用 allMarkdownRemark。这样做有什么具体原因吗?
【问题讨论】: