diff --git a/src/components/MDX/ErrorDecoder.tsx b/src/components/MDX/ErrorDecoder.tsx
index 423790198bf..61ff261aeb8 100644
--- a/src/components/MDX/ErrorDecoder.tsx
+++ b/src/components/MDX/ErrorDecoder.tsx
@@ -8,6 +8,7 @@
import {useEffect, useState} from 'react';
import {useErrorDecoderParams} from '../ErrorDecoderContext';
import cn from 'classnames';
+import {IconError} from '../Icon/IconError';
function replaceArgs(
msg: string,
@@ -108,12 +109,48 @@ export default function ErrorDecoder() {
}, [errorCode, hasParams, errorMessage]);
return (
-
- {message}
-
+ )}
+ translate="no"
+ dir="ltr">
+
+
+
);
}
diff --git a/src/pages/errors/[errorCode].tsx b/src/pages/errors/[errorCode].tsx
index 67466a1d991..5e3acd94f7b 100644
--- a/src/pages/errors/[errorCode].tsx
+++ b/src/pages/errors/[errorCode].tsx
@@ -20,26 +20,33 @@ interface ErrorDecoderProps {
content: string;
toc: string;
meta: any;
+ isCustom: boolean;
}
export default function ErrorDecoderPage({
errorMessage,
errorCode,
content,
+ toc,
+ isCustom,
}: InferGetStaticPropsType) {
const parsedContent = useMemo(
() => JSON.parse(content, reviveNodeOnClient),
[content]
);
+ const parsedToc = useMemo(
+ () => (isCustom ? JSON.parse(toc, reviveNodeOnClient) : []),
+ [toc, isCustom]
+ );
return (
@@ -117,11 +124,13 @@ export const getStaticProps: GetStaticProps = async ({
// Read MDX from the file.
let path = params?.errorCode || 'index';
let mdx;
+ let isCustom = true;
try {
mdx = fs.readFileSync(rootDir + '/' + path + '.md', 'utf8');
} catch {
// if [errorCode].md is not found, fallback to generic.md
mdx = fs.readFileSync(rootDir + '/generic.md', 'utf8');
+ isCustom = false;
}
const {content, toc, meta} = await compileMDX(mdx, path, {code, errorCodes});
@@ -131,6 +140,7 @@ export const getStaticProps: GetStaticProps = async ({
content,
toc,
meta,
+ isCustom,
errorCode: code,
errorMessage: code ? errorCodes[code] : null,
},