Skip to content

Commit

Permalink
refactor: change output props to renderImage
Browse files Browse the repository at this point in the history
  • Loading branch information
rayriffy committed May 1, 2023
1 parent 08be597 commit 9dd3a53
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/warm-pans-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@contentsgarten/html': minor
---

Remove `renderCode` options, and replacing with `renderImage` instead
6 changes: 3 additions & 3 deletions packages/html/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface Html {
html: string
customComponents?: MarkdownCustomComponents
renderLink?: (props: LinkProps) => JSX.Element
renderCode?: (props: HTMLAttributes<HTMLElement>) => JSX.Element
renderImage?: (props: HTMLAttributes<HTMLImageElement>) => JSX.Element
}

export function isWikiLink(props: { href: string }) {
Expand All @@ -49,7 +49,7 @@ export const Html: FC<Html> = (props) => {
if (
node.type === 'tag' &&
'name' in node &&
node.name === 'code'
node.name === 'img'
) {
// Don't replace links twice.
return
Expand All @@ -58,7 +58,7 @@ export const Html: FC<Html> = (props) => {
}
}))
if (typeof element !== 'object') return
return props.renderCode?.(element.props) || undefined
return props.renderImage?.(element.props) || undefined
}

function replaceLink() {
Expand Down

0 comments on commit 9dd3a53

Please sign in to comment.