-
Notifications
You must be signed in to change notification settings - Fork 3
Embedded Images #25
Comments
@maxscience you might be interested in this |
@maxscience... wanna give Here's a demo |
@PaulieScanlon cool! It looks like the width props don't make the image correctly responsive (in your demo the image will get 100% width at smartphone size but not at desktop computer window width. Also I see you have the flex-start, center and flex-end props for justifyContent but it would be very useful to have proper layout options so that images can be inline with the text. Similar to layouts at https://rmarkdown.rstudio.com/flexdashboard/layouts.html or https://github.com/cedricdelpoux/gatsby-remark-images-grid or your very own https://gatsby-remark-grid-system.netlify.com |
Hey @maxscience width accepts a string or an array of x4 possible percentages across the 4 breakpoints. What happens if you do width=“100%” Or width={[“100%” ... rest of percentages]} The display props would be handy, but in
if in In either case you can add that plugin to your site and extend from the theme. |
I think in both cases it would be very useful to have responsive grid layouts done in markdown. Why not just integrate your own plugin https://gatsby-remark-grid-system.netlify.com ? 🥇 |
Btw I've used test code from https://theme-ui.com/layout/ and https://rebassjs.org/flex |
@maxscience i guess i'm keen to not implement a whole load of plugins and just let the user decided which additional plugins they want. Did you implement |
@PaulieScanlon no repo yet but this is my page in .mdx `---
|
P.S. yes I did install gatsby-plugin-theme-ui |
ah ok, yeah i don't think you can import them straight into I'm not actually sure what the best approach is here. On one had if you need that level of control perhaps just using Alternatively you could create a layout component which has some render props so you can pass though content and it'll return you the flex and box etc but that seems like a bit of a faff. |
it looks like the best solution is really your gatsby-remark-grid-system |
Ha, yeah maybe so but i don't think it'll work with If the |
Yes indeed as I was thinking. So it's tied with #23 and I guess the best way to solve both is: |
Btw not sure what this mdx is for then if one can't even use simple react layouts without headaches... This is a simple use case that should be simple enough to use. :) |
@maxscience ok, so what you need is some-post.mdx ---
frontmatter
---
`import { Flex, Box } from '@theme-ui/components'`
<Flex
sx={{
flexWrap: 'wrap'
}}
>
<Box
sx={{
p: 8,
width: ['100%', '100%', '50%']
}}
>
left content
</Box>
<Box
sx={{
p: 8,
width: ['100%', '100%', '50%']
}}
>
right content
</Box>
</Flex> |
@theme-ui/components is not there so webpack rightfully complains it can't generate the bundle. Quickly tried with |
@maxscience you’ll need to install it, it’s not part of the theme. |
@PaulieScanlon hah indeed, it was a bit late sorry. It works now thanks! |
P.S. interesting that some markdown will break the template. For example using an unordered list like so will result in the error below. In this case it looks like there is no closing li tag `frontmatter import { EmbeddedImage } from "@pauliescanlon/gatsby-theme-gatstats/src/components/EmbeddedImage" asdsad <Flex <Box
` error: "gatsby-plugin-mdx" threw an error while running the onCreateNode lifecycle: unknown: Expected corresponding JSX closing tag for 21 | 22 | {
21 | 22 | {
SyntaxError: unknown: Expected corresponding JSX closing tag for 21 | 22 | < 39mstrong parentName="p">{
success source and transform nodes - 1.286s ERROR #85901 GRAPHQL There was an error in your GraphQL query: Expected type MdxFieldsEnum, found frontmatter___date. Did you mean the enum value frontmatter___title or frontmatter___icon? File: node_modules/@pauliescanlon/gatsby-theme-gatstats/src/components/CardList/CardListContainer.tsx:24:48 ERROR #85901 GRAPHQL There was an error in your GraphQL query: Expected type MdxFieldsEnum, found frontmatter___tags. Did you mean the enum value frontmatter___title or frontmatter___icon? File: node_modules/@pauliescanlon/gatsby-theme-gatstats/src/components/CardList/CardListContainer.tsx:25:26 ERROR #85901 GRAPHQL There was an error in your GraphQL query: Expected type MdxFieldsEnum, found frontmatter___date. Did you mean the enum value frontmatter___title or frontmatter___icon? File: node_modules/@pauliescanlon/gatsby-theme-gatstats/src/components/DaysChart/DaysChartContainer.tsx:37:30 ERROR #85901 GRAPHQL There was an error in your GraphQL query: Expected type MdxFieldsEnum, found frontmatter___date. Did you mean the enum value frontmatter___title or frontmatter___icon? File: node_modules/@pauliescanlon/gatsby-theme-gatstats/src/components/LatestPosts/LatestPostsContainer.tsx:17:43 ERROR #85901 GRAPHQL There was an error in your GraphQL query: Expected type MdxFieldsEnum, found frontmatter___date. Did you mean the enum value frontmatter___title or frontmatter___icon? File: node_modules/@pauliescanlon/gatsby-theme-gatstats/src/components/TagsChart/TagsChartContainer.tsx:26:43 ERROR #85901 GRAPHQL There was an error in your GraphQL query: Expected type MdxFieldsEnum, found frontmatter___tags. Did you mean the enum value frontmatter___title or frontmatter___icon? File: node_modules/@pauliescanlon/gatsby-theme-gatstats/src/components/TagsChart/TagsChartContainer.tsx:28:26 ERROR #85901 GRAPHQL There was an error in your GraphQL query: Expected type MdxFieldsEnum, found frontmatter___date. Did you mean the enum value frontmatter___title or frontmatter___icon? File: node_modules/@pauliescanlon/gatsby-theme-gatstats/src/components/YearChart/YearChartContainer.tsx:50:43 ERROR #85901 GRAPHQL There was an error in your GraphQL query: Cannot query field "tags" on type "MdxFrontmatter". GraphQL request:19:9 File: node_modules/@pauliescanlon/gatsby-theme-gatstats/src/layouts/post.tsx:159:9 ERROR #85901 GRAPHQL There was an error in your GraphQL query: Cannot query field "date" on type "MdxFrontmatter". GraphQL request:20:9 File: node_modules/@pauliescanlon/gatsby-theme-gatstats/src/layouts/post.tsx:160:9 ERROR #85901 GRAPHQL There was an error in your GraphQL query: Cannot query field "featuredImage" on type "MdxFrontmatter". GraphQL request:21:9 File: node_modules/@pauliescanlon/gatsby-theme-gatstats/src/layouts/post.tsx:161:9 ERROR #85901 GRAPHQL There was an error in your GraphQL query: Cannot query field "embeddedImages" on type "MdxFrontmatter". GraphQL request:31:9 File: node_modules/@pauliescanlon/gatsby-theme-gatstats/src/layouts/post.tsx:171:9 failed extract queries from components - 0.836s |
frontmatter already deals with the featuredImage which gets added to the top of each post.
If further images are required in a post it would be nice to query additional frontmatter so that MdxRenderer can be passed data for embedded images.
The key difference is i guess that if we pass MdxRenderer the graphQL image query as a prop it can be used anywhere in the body of the post
eg
Post body text
More post body text
The text was updated successfully, but these errors were encountered: