Giter Site home page Giter Site logo

rehype-mdx-import-media's Issues

`visit()` video elements of type `mdxJsxFlowElement`?

Hi @remcohaszing 👋

I'm trying this out in our project, and I noticed that I am getting a different data structure than is maybe expected for video elements:

node {
  type: 'mdxJsxFlowElement',
  name: 'video',
  attributes: [
    {
      type: 'mdxJsxAttribute',
      name: 'src',
      value: './expo-android-virtual-device-start-expo-go.mp4',
      position: [Object]
    },
    {
      type: 'mdxJsxAttribute',
      name: 'controls',
      value: null,
      position: [Object]
    },
    {
      type: 'mdxJsxAttribute',
      name: 'style',
      value: [Object],
      position: [Object]
    }
  ],
  position: {
    start: { line: 7, column: 1, offset: 228 },
    end: { line: 16, column: 3, offset: 411 }
  },
  data: { _mdxExplicitJsx: true },
  children: []
}

This is for the following MDX:

<video
 src="./expo-android-virtual-device-start-expo-go.mp4"
 controls
 style={{
   minWidth: 480,
   maxWidth: '70%',
   margin: '0 auto 1.45em',
   display: 'block',
 }}
/>

Would it be an idea to change the 'element' on the line below to ['element', 'mdxJsxFlowElement']?

visit(ast, 'element', (node, index, parent) => {

I'm thinking there will probably be other changes needed too for the attributes... 🤔

Document usage of imports with Next.js + webpack v5?

When using rehype-mdx-import-media with @next/mdx (Next.js with webpack v5), usage of rehype-mdx-import-media with a video URL (eg. *.mp4) fails because of a missing loader:

 ⨯ ../cheatsheet-expo-react-native/expo-android-virtual-device-close-app.mp4
Module parse failed: Unexpected character '' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)

Import trace for requested module:
../cheatsheet-expo-react-native/expo-android-virtual-device-close-app.mp4
../cheatsheet-expo-react-native/index.mdx
./app/page.tsx

Screenshot 2024-06-30 at 15 05 00

It would be great for users to have recipes in the documentation that they could copy and paste, so that the plugin works out of the box.

import losing search params

I am trying to use this in NextJS app router with mdx files. I have the img tags being replaced by a custom component that reads the search param from the path and uses it to size the image. However, when I add this plugin, while the local image load works nicely, I lose the query param. Can it be preserved in the path, or moved to a different attribute?

Example MDX:

![alt text](images/IMG_1641-2.jpg?w=full)
![alt text](images/IMG_1643.jpg?w=400&h=300)

If there is a way to add more attributes, that is not clear from the documentation. Any help appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.