@@ -3,12 +3,13 @@ import * as runtime from "react/jsx-runtime";
33import * as R from "remeda" ;
44
55import { evaluate , EvaluateOptions } from "@mdx-js/mdx" ;
6- import { Button , CircularProgress , Typography } from "@mui/material" ;
6+ import { CircularProgress } from "@mui/material" ;
77import { ErrorBoundary , Suspense } from "@suspensive/react" ;
88import { useSuspenseQuery } from "@tanstack/react-query" ;
99import components , { MuiMdxComponentsOptions } from 'mui-mdx-components' ;
1010
11- import { useCommonContext } from '../hooks/useCommonContext' ;
11+ import Components from "../components" ;
12+ import Hooks from "../hooks" ;
1213
1314const MDXComponents : MuiMdxComponentsOptions = {
1415 overrides : {
@@ -26,41 +27,6 @@ const MDXComponents: MuiMdxComponentsOptions = {
2627 }
2728}
2829
29- const SimplifiedMDXErrorFallback : React . FC < { reset : ( ) => void } > = ( { reset } ) => {
30- return < >
31- < Typography variant = "body2" color = "error" >
32- 페이지를 그리던 중 문제가 발생했습니다, 잠시 후 다시 시도해주세요.< br />
33- 만약 문제가 계속 발생한다면, 파이콘 한국 준비 위원회에게 알려주세요!< br />
34- < br />
35- Problem occurred while drawing the page, please try again later.< br />
36- If the problem persists, please let the PyCon Korea organizing committee know!
37- </ Typography >
38- < br />
39- < Button variant = "outlined" onClick = { reset } > 다시 시도 | Retry</ Button >
40- </ > ;
41- }
42-
43- const DetailedMDXErrorFallback : React . FC < { error : Error , reset : ( ) => void } > = ( { error, reset } ) => {
44- const errorObject = Object . getOwnPropertyNames ( error ) . reduce ( ( acc , key ) => ( { ...acc , [ key ] : ( error as unknown as { [ key : string ] : unknown } ) [ key ] } ) , { } ) ;
45- return < >
46- < Typography variant = "body2" color = "error" > MDX 변환 오류: { error . message } </ Typography >
47- < details open >
48- < summary > 오류 상세</ summary >
49- < pre style = { {
50- whiteSpace : "pre-wrap" ,
51- backgroundColor : "#f5f5f5" ,
52- padding : "1em" ,
53- borderRadius : "4px" ,
54- userSelect : "text" ,
55- } } >
56- < code > { JSON . stringify ( errorObject , null , 2 ) } </ code >
57- </ pre >
58- </ details >
59- < br />
60- < Button variant = "outlined" onClick = { reset } > 다시 시도</ Button >
61- </ > ;
62- } ;
63-
6430const InnerMDXRenderer : React . FC < { text : string , baseUrl : string } > = ( { text, baseUrl } ) => {
6531 const options : EvaluateOptions = { ...runtime , baseUrl } ;
6632
@@ -92,16 +58,15 @@ const lineFormatterForMDX = (line: string) => {
9258export const MDXRenderer : React . FC < { text : string } > = ( { text } ) => {
9359 // 원래 MDX는 각 줄의 마지막에 공백 2개가 있어야 줄바꿈이 되고, 또 연속 줄바꿈은 무시되지만,
9460 // 편의성을 위해 렌더러 단에서 공백 2개를 추가하고 연속 줄바꿈을 <br />로 변환합니다.
95- const { baseUrl, debug } = useCommonContext ( ) ;
61+ const { baseUrl, debug } = Hooks . useCommonContext ( ) ;
9662
97- const ErrorHandler = debug ? DetailedMDXErrorFallback : SimplifiedMDXErrorFallback ;
9863 const processedText = text
9964 . split ( "\n" )
10065 . map ( lineFormatterForMDX )
10166 . join ( "" )
10267 . replaceAll ( "\n\n" , "\n<br />\n" ) ;
10368
104- return < ErrorBoundary fallback = { ErrorHandler } >
69+ return < ErrorBoundary fallback = { Components . ErrorFallback } >
10570 < Suspense fallback = { < CircularProgress /> } >
10671 < InnerMDXRenderer text = { processedText } baseUrl = { baseUrl } />
10772 </ Suspense >
0 commit comments