-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
62 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'myst-to-react': patch | ||
--- | ||
|
||
Support various types of margin content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import type { NodeRenderer } from '@myst-theme/providers'; | ||
import { MyST } from './MyST.js'; | ||
import type { GenericNode } from 'myst-common'; | ||
|
||
type Aside = { | ||
type: 'aside'; | ||
}; | ||
|
||
function getAsideClass(kind?: string) { | ||
switch (kind) { | ||
case 'topic': | ||
return { | ||
container: 'my-5 shadow dark:bg-stone-800 overflow-hidden dark:border-l-4 border-slate-400', | ||
title: | ||
'm-0 font-medium py-2 px-4 flex min-w-0 text-md border-y dark:border-y-0 bg-gray-50/80 dark:bg-slate-900', | ||
body: 'px-4', | ||
}; | ||
case 'margin': | ||
case 'sidebar': | ||
default: | ||
return { | ||
container: 'text-sm lg:h-0 col-margin-right', | ||
title: 'text-base font-semibold', | ||
body: '', | ||
}; | ||
} | ||
} | ||
|
||
export const AsideRenderer: NodeRenderer<Aside> = ({ node }) => { | ||
const [title, ...rest] = node.children as GenericNode[]; | ||
const className = getAsideClass(node.kind); | ||
if (title.type !== 'admonitionTitle') { | ||
return ( | ||
<aside className={className.container}> | ||
<MyST ast={node.children} /> | ||
</aside> | ||
); | ||
} | ||
return ( | ||
<aside className={className.container}> | ||
<div className={className.title}> | ||
<MyST ast={title} /> | ||
</div> | ||
<div className={className.body}> | ||
<MyST ast={rest} /> | ||
</div> | ||
</aside> | ||
); | ||
}; | ||
|
||
const ASIDE_RENDERERS = { | ||
aside: AsideRenderer, | ||
}; | ||
|
||
export default ASIDE_RENDERERS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters