Accessing blogs from custom page #4800
-
Hi, I would like to render a little carousel of the most recent blogs on my index page. const data = useStaticQuery(graphql`
query getIndexPageData {
allMdx(
limit: 3
filter: { frontmatter: { path: { glob: "/blog/**/*" } } }
sort: { fields: [frontmatter___date], order: DESC }
) {
edges {
node {
id
fields {
readingTime {
text
}
}
frontmatter {
featuredImage {
childImageSharp {
fluid(maxWidth: 800, pngQuality: 90) {
...GatsbyImageSharpFluid
}
}
}
path
title
date(formatString: "MMMM DD, YYYY")
}
}
}
}
}
`); Is something like this possible with Docusaurus? Can I access the frontmatter? usePluginData("docusaurus-plugin-content-blog"); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
We don't support to query plugin data with GraphQL like Gatbsy does. It is however possible to achieve what you want in various ways:
We also plan to allow you to "extend" an existing content plugin: for example you'll be able to add a blog index page by reusing the internal data that the blog plugin already read on the filesystem. Some discussions here: #4138 If you want to create an index page that involves reading the data of multiple plugins, unfortunately I'm not sure we'll be able to solve this problem easily, as unlike Gatsby, we don't have a unified data cache that you can query in different ways according to your usecase. I'll need to think about this more to see if a solution is possible. |
Beta Was this translation helpful? Give feedback.
We don't support to query plugin data with GraphQL like Gatbsy does.
It is however possible to achieve what you want in various ways:
loadContent
+contentLoaded
+addRoute
to create your homepage (equivalent of creating a page with Gatsby node)I admit it is not ideal but I don't have many other alternatives.
We also plan to allow you to "extend" an existing content plugin: for example you'll be able to add a blog index page by reusing the internal data that the blog plugin already read on the filesystem. Some discussions here: #4138
If you want t…