Skip to content

Commit

Permalink
allow line code in notes
Browse files Browse the repository at this point in the history
  • Loading branch information
shahednasser committed Aug 19, 2024
1 parent bb5009b commit 1dd2f43
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions www/packages/docs-ui/src/components/Note/Layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export const NoteLayout = ({ type, title, children }: NoteLayoutProps) => {
"children" in child.props &&
child.props.children
) {
if (child.type.toString().includes(`"li"`)) {
const typeStr = child.type.toString()
if (typeStr.includes(`"li"`)) {
allStringChildren = false
return
} else if (
Expand All @@ -40,6 +41,12 @@ export const NoteLayout = ({ type, title, children }: NoteLayoutProps) => {
) {
stringChildren.push(`[${child.props.children}](${child.props.href})`)
return
} else if (
typeStr.includes("InlineCode") &&
typeof child.props.children === "string"
) {
stringChildren.push(`\`${child.props.children}\``)
return
}

const childInfo = getStringInfoFromChildren(
Expand Down Expand Up @@ -91,7 +98,10 @@ export const NoteLayout = ({ type, title, children }: NoteLayoutProps) => {
{title}: 
</span>
{allStringChildren && (
<MarkdownContent allowedElements={["a"]} unwrapDisallowed={true}>
<MarkdownContent
allowedElements={["a", "code"]}
unwrapDisallowed={true}
>
{stringChildren}
</MarkdownContent>
)}
Expand Down

0 comments on commit 1dd2f43

Please sign in to comment.