A UI field for building block-based pages with MDX #2429
Replies: 2 comments 5 replies
-
As mentioned in office hours, there's one thing to consider for this feature, which is that mdx as it stands today is that there's no way to control what data you get from those blocks, so for the example above the payload might look like this: [
{
_template: "Hero",
title: "Hello, World!",
},
{
_template: "Features",
items: [//etc]
},
{
_template: "Content",
body: "..."
}
] That would work fine, but if you had a "FeatureBlog" section, we'd want to resolve some data across to each blog post: {
_template: "FeaturedBlogs",
posts: [
{
title: "Hello, World!",
}
]
} But since the query would look like this: {
getPageDocument(relativePath: $relativePath) {
data {
blocks
}
}
} We don't have anywhere to tell GraphQL that it needs to resolve blog lists. What we probably want instead is something like this: {
getPageDocument(relativePath: $relativePath) {
data {
blocks {
embeddedObjects {
...on Hero {
title
}
...on Features {
items { ... }
}
...on Content {
body
}
# Doing it this way allows us to resolve across nodes
...on FeaturedBlogs {
data {
title
}
}
}
ast # this would be the actual data
}
}
}
} This is discussed a bit more in the MDX pitch under the "Bonus" section https://github.com/tinacms/product-archive/discussions/26 |
Beta Was this translation helpful? Give feedback.
-
I am very much looking forward to this feature. Any chance there is an estimate on when this feature would be released? |
Beta Was this translation helpful? Give feedback.
-
Dealing with YAML in .md files for block-based pages (like the approach we describe here) often feels overly complex. When you have page with a lot of blocks, you easily can get 100s of lines of YAML. For a front-end developer, it's often much simpler/quicker to use MDX components for block-based pages.
Having a UI field that allows editors to use MDX but without the rich-text chrome would be ideal for these types of pages. We would get the DX of using MDX components for block-based layouts and the UX of our existing block solution, like so:
If the user wanted to insert a markdown text between blocks, you could do that with an MDX component that includes a rich text field
Beta Was this translation helpful? Give feedback.
All reactions