diff --git a/lib/markdown.tsx b/lib/markdown.tsx
index e33d86b..d8132ac 100644
--- a/lib/markdown.tsx
+++ b/lib/markdown.tsx
@@ -8,14 +8,23 @@ import imgSize from "rehype-img-size";
import highlight from "rehype-highlight";
import { common } from "lowlight";
import groovy from "highlight.js/lib/languages/groovy";
-import react from "rehype-react";
+import react, { Components } from "rehype-react";
import Image from "next/image";
import Link from "next/link";
import isAbsoluteUrl from "is-absolute-url";
-// @ts-expect-error: the react types are missing.
const production = { Fragment: prod.Fragment, jsx: prod.jsx, jsxs: prod.jsxs };
+const components = {
+ img: (props) => ,
+ a: (props) =>
+ props.href && isAbsoluteUrl(props.href) ? (
+
+ ) : (
+
+ ),
+} as Components;
+
export const getReactElementFromMarkdown = async (md: string) => {
const file = await unified()
.use(markdown)
@@ -26,16 +35,8 @@ export const getReactElementFromMarkdown = async (md: string) => {
.use(highlight, { detect: true, languages: { ...common, groovy } })
.use(react, {
...production,
- components: {
- img: (props: any) => ,
- a: (props: any) =>
- isAbsoluteUrl(props.href) ? (
-
- ) : (
-
- ),
- },
- })
+ components,
+ } as any)
.process(md);
return file.result;