Skip to content

Commit

Permalink
fix: add base conditions on clsx wrapper for MDX components
Browse files Browse the repository at this point in the history
  • Loading branch information
thedevwonder committed Jun 28, 2023
1 parent ae2a093 commit 6841243
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import type {Props} from '@theme/MDXComponents/Img';

import styles from './styles.module.css';

function transformImgClassName(className?: string): string {
return clsx(className, styles.img);
function transformImgClassName(className?: string): string | undefined {
return !className ? undefined : clsx(className, styles.img);
}

export default function MDXImg(props: Props): JSX.Element {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ import type {Props} from '@theme/MDXComponents/Ul';

import styles from './styles.module.css';

function transformUlClassName(className?: string): string {
return clsx(
className,
// This class is set globally by GitHub/MDX. We keep the global class, and
// add another class to get a task list without the default ul styling
// See https://github.com/syntax-tree/mdast-util-to-hast/issues/28
className?.includes('contains-task-list') && styles.containsTaskList,
);
function transformUlClassName(className?: string): string | undefined {
return !className
? undefined
: clsx(
className,
// This class is set globally by GitHub/MDX. We keep the global class,
// and add another class to get a task list without the default ul
// styling
// See https://github.com/syntax-tree/mdast-util-to-hast/issues/28
className?.includes('contains-task-list') && styles.containsTaskList,
);
}

export default function MDXUl(props: Props): JSX.Element {
Expand Down

0 comments on commit 6841243

Please sign in to comment.