Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't load png files in mdx with default bundler #2

Closed
bitwhys opened this issue Jun 20, 2024 · 3 comments
Closed

Can't load png files in mdx with default bundler #2

bitwhys opened this issue Jun 20, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@bitwhys
Copy link
Owner

bitwhys commented Jun 20, 2024

✘ [ERROR] No loader is configured for ".png" files: planetaria-design-system.png

_mdx_bundler_entry_point-18d05a67-7c94-41ef-8d45-ce79186b1241.mdx:8:25:
  8 │ import designSystem from './planetaria-design-system.png';
@bitwhys bitwhys added the bug Something isn't working label Jun 20, 2024
@bitwhys
Copy link
Owner Author

bitwhys commented Jun 21, 2024

From the contentlayer docs:

Contentlayer does not currently support image processing

Add support for importing images issue in contentlayer repo

@bitwhys
Copy link
Owner Author

bitwhys commented Jun 21, 2024

Suggested solution

Lean on Framework

Some frameworks like Next.js come with the ability to process images on the server side, providing the optimal image based on the current viewport size. When the framework has this tooling available, you can often use images stored either locally or remotely.


Documentation

Working with Images

Image processing with Contentlayer is not currently supported, although we're planning on it. The current recommendation is to place images in the public directory, and then use a string field to store the path to that image.

Alternatively, you can store your images in an asset service like Cloudinary or Imgix. See here for more detail on our current recommendation for image processing.

Using next/image in Body Content

If you want to use next/image to render your images, create a component to wrap next/image and add the image via component markup in your markdown or MDX file.

For example, say we have an Image component in our project that wraps the next/image.

import NextImage from 'next/image'

const Image = (props) => {
  return <NextImage /* ... */ />
}

Your content should then call this component directly.

Other markdown content ...

<Image src="..." />

You can either use an .mdx file to have this content processed automatically, or you can use a tool like markdown-to-jsx with raw markdown.

@bitwhys
Copy link
Owner Author

bitwhys commented Jun 23, 2024

commit 181c594 fixes this issue

@bitwhys bitwhys closed this as completed Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant