Skip to content

Commit

Permalink
feat(docs): Allow custom components before DocItems (#4144)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Electron authored Dec 5, 2024
1 parent 1b4ca89 commit 4fd9abc
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/site/configs/preContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from 'react';
import Admonition from '@theme/Admonition';

export default {
'/iota-identity*': <Admonition type='info'>IOTA Identity is currently in alpha and may still be subject to significant changes</Admonition>,
};
26 changes: 26 additions & 0 deletions docs/site/src/theme/DocItem/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* SWIZZLED VERSION: 3.5.2
* REASONS:
* - Add option to allow custom components before the DocItem
*/
import React from 'react';
import DocItem from '@theme-original/DocItem';
import type DocItemType from '@theme/DocItem';
import type {WrapperProps} from '@docusaurus/types';
import { useLocation } from '@docusaurus/router';

import preMDXComponents from '../../../configs/preContent';

type Props = WrapperProps<typeof DocItemType>;

export default function DocItemWrapper(props: Props): JSX.Element {
const { pathname } = useLocation();
const matchingKey = Object.keys(preMDXComponents).find((key) => new RegExp(key).test(pathname));

return (
<>
{preMDXComponents[matchingKey]}
<DocItem {...props} />
</>
);
}
1 change: 1 addition & 0 deletions docs/site/src/theme/MDXContent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* SWIZZLED VERSION: 3.5.2
* REASONS:
* - Add default components
* - Add FeedbackForm component
*/
import React from 'react';
import { MDXProvider } from '@mdx-js/react';
Expand Down

0 comments on commit 4fd9abc

Please sign in to comment.