mdx-js / mdx

Markdown for the component era
https://mdxjs.com
MIT License
17.76k stars 1.14k forks source link

Patch version 3.0.0 to 3.0.1 killed all admonitions #2441

Closed dimisus closed 9 months ago

dimisus commented 9 months ago

Initial checklist

Affected packages and versions

Docusaurus 3.1.1

Link to runnable example

No response

Steps to reproduce

Upgrade 3.0.0 to 3.0.1

Expected behavior

Admonitions remain visible

Actual behavior

Admonitions are not visible


// Custom admonitions extension
import React from 'react';
import { LiaConnectdevelop } from 'react-icons/lia';
import { FaDev } from 'react-icons/fa';
import { MdFactory } from 'react-icons/md';
import { ImNext } from 'react-icons/im';

import DefaultAdmonitionTypes from '@theme-original/Admonition/Types';
import { Props as AdmonitionProps } from '@theme/Admonition';
import AdmonitionLayout from '@theme/Admonition/Layout';
import clsx from 'clsx';

const CustomAdmonitionIconPickerByType = ({ type }: { type: string }) =>
  ({
    devnet: <LiaConnectdevelop />,
    production: <MdFactory />,
    next: <ImNext />,
    development: <FaDev />,
  })[type];

function MyCustomAdmonition(props: AdmonitionProps) {
  const { title, type, children } = props;

  return (
    <AdmonitionLayout
      type={type}
      title={title || type.toUpperCase()}
      className={clsx(['theme-admonition-custom', 'alert'])}
      icon={<CustomAdmonitionIconPickerByType type={type} />}
    >
      {children}
    </AdmonitionLayout>
  );
}

const AdmonitionTypes = {
  ...DefaultAdmonitionTypes,

  // Add all your custom admonition types here...
  // You can also override the default ones if you want
  devnet: MyCustomAdmonition,
  production: MyCustomAdmonition,
  next: MyCustomAdmonition,
  development: MyCustomAdmonition,
};

export default AdmonitionTypes;

Runtime

Node v21

Package manager

yarn v4

OS

macOS

Build and bundle tools

Other (please specify in steps to reproduce)

ChristianMurphy commented 9 months ago

Welcome @dimisus! Sorry you ran into a spot of trouble.

Admonitions are not a part of mdx. There are also many different and competing admonition implementations out there. This is an issue in the admonition plugin you are leveraging.

I'd also speculate the issue is unrelated to mdx entirely. Version 3.0.0 to 3.0.1 did not modify the parser (what the admonition plugin extends/modifies) https://github.com/mdx-js/mdx/releases/tag/3.0.1

ChristianMurphy commented 9 months ago

Also now that you've updated the issue with some sample code, you don't appear to be using MDX at all?