@@ -5,13 +5,15 @@ import rehypeKatex from 'rehype-katex';
5
5
import remarkGfm from 'remark-gfm' ;
6
6
import remarkMath from 'remark-math' ;
7
7
8
+ import { WithNavBanner } from '@/components/blocks/authed/with-nav-banner' ;
8
9
import { Badge } from '@/components/ui/badge' ;
9
10
import { Card , CardContent , CardHeader , CardTitle } from '@/components/ui/card' ;
10
11
import { ScrollArea } from '@/components/ui/scroll-area' ;
11
12
import { Separator } from '@/components/ui/separator' ;
13
+
14
+ import { useCrumbs } from '@/lib/hooks/use-crumbs' ;
15
+ import { usePageTitle } from '@/lib/hooks/use-page-title' ;
12
16
import { getQuestionDetails } from '@/services/question-service' ;
13
- import { useBreadCrumbs } from '@/stores/breadcrumb-store' ;
14
- import { useEffect } from 'react' ;
15
17
16
18
const questionDetailsQuery = ( id : number ) =>
17
19
queryOptions ( {
@@ -30,68 +32,66 @@ export const loader =
30
32
export const QuestionDetails = ( ) => {
31
33
const { questionId } = useLoaderData ( ) as Awaited < ReturnType < ReturnType < typeof loader > > > ;
32
34
const { data : details } = useSuspenseQuery ( questionDetailsQuery ( questionId ) ) ;
33
- const { setCrumbs } = useBreadCrumbs ( ) ;
34
- useEffect ( ( ) => {
35
- if ( details && setCrumbs ) {
36
- setCrumbs ( ( c ) => [ ...c , { path : '' , title : `${ questionId } . ${ details . title } ` } ] ) ;
37
- }
38
- } , [ ] ) ;
35
+ const { crumbs } = useCrumbs ( { path : '<CURRENT>' , title : `${ questionId } . ${ details . title } ` } ) ;
36
+ usePageTitle ( details . title ) ;
39
37
40
38
return (
41
- < div className = 'flex flex-1 overflow-hidden' >
42
- < Card className = 'border-border m-4 w-1/3 max-w-[500px] overflow-hidden p-4 md:w-2/5' >
43
- < ScrollArea className = 'h-full' >
44
- < CardHeader >
45
- < div className = 'flex flex-col gap-4' >
46
- < div className = 'flex w-full items-center gap-4' >
47
- < CardTitle className = 'text-2xl' >
48
- { details . id } . { details . title }
49
- </ CardTitle >
50
- </ div >
51
- < div className = 'flex flex-wrap items-center gap-1' >
52
- < Badge variant = 'secondary' className = 'flex w-min grow-0' >
53
- { details . difficulty }
54
- </ Badge >
55
- < Separator orientation = 'vertical' className = 'mx-2 h-4' />
56
- < span className = 'text-sm font-medium' > Topics:</ span >
57
- { details . topics . map ( ( v , i ) => (
58
- < Badge
59
- variant = 'secondary'
60
- className = 'flex w-min grow-0 whitespace-nowrap'
61
- key = { i }
62
- >
63
- { v }
39
+ < WithNavBanner crumbs = { [ ...crumbs ] } >
40
+ < div className = 'flex flex-1 overflow-hidden' >
41
+ < Card className = 'border-border m-4 w-1/3 max-w-[500px] overflow-hidden p-4 md:w-2/5' >
42
+ < ScrollArea className = 'h-full' >
43
+ < CardHeader >
44
+ < div className = 'flex flex-col gap-4' >
45
+ < div className = 'flex w-full items-center gap-4' >
46
+ < CardTitle className = 'text-2xl' >
47
+ { details . id } . { details . title }
48
+ </ CardTitle >
49
+ </ div >
50
+ < div className = 'flex flex-wrap items-center gap-1' >
51
+ < Badge variant = 'secondary' className = 'flex w-min grow-0' >
52
+ { details . difficulty }
64
53
</ Badge >
65
- ) ) }
54
+ < Separator orientation = 'vertical' className = 'mx-2 h-4' />
55
+ < span className = 'text-sm font-medium' > Topics:</ span >
56
+ { details . topics . map ( ( v , i ) => (
57
+ < Badge
58
+ variant = 'secondary'
59
+ className = 'flex w-min grow-0 whitespace-nowrap'
60
+ key = { i }
61
+ >
62
+ { v }
63
+ </ Badge >
64
+ ) ) }
65
+ </ div >
66
66
</ div >
67
- </ div >
68
- </ CardHeader >
69
- < CardContent >
70
- < Markdown
71
- rehypePlugins = { [ rehypeKatex ] }
72
- remarkPlugins = { [ remarkMath , remarkGfm ] }
73
- className = 'prose prose-neutral text-card-foreground prose-strong:text-card-foreground leading-normal'
74
- components = { {
75
- code : ( { children, className, ...rest } ) => {
76
- // const isCodeBlock = /language-(\w+)/.exec(className || '');
67
+ </ CardHeader >
68
+ < CardContent >
69
+ < Markdown
70
+ rehypePlugins = { [ rehypeKatex ] }
71
+ remarkPlugins = { [ remarkMath , remarkGfm ] }
72
+ className = 'prose prose-neutral text-card-foreground prose-strong:text-card-foreground leading-normal'
73
+ components = { {
74
+ code : ( { children, className, ...rest } ) => {
75
+ // const isCodeBlock = /language-(\w+)/.exec(className || '');
77
76
78
- return (
79
- < code
80
- { ...rest }
81
- className = 'bg-secondary text-secondary-foreground rounded px-1.5 py-1 font-mono'
82
- >
83
- { children }
84
- </ code >
85
- ) ;
86
- } ,
87
- } }
88
- >
89
- { details . description }
90
- </ Markdown >
91
- </ CardContent >
92
- </ ScrollArea >
93
- </ Card >
94
- < div className = 'flex flex-1 flex-col' />
95
- </ div >
77
+ return (
78
+ < code
79
+ { ...rest }
80
+ className = 'bg-secondary text-secondary-foreground rounded px-1.5 py-1 font-mono'
81
+ >
82
+ { children }
83
+ </ code >
84
+ ) ;
85
+ } ,
86
+ } }
87
+ >
88
+ { details . description }
89
+ </ Markdown >
90
+ </ CardContent >
91
+ </ ScrollArea >
92
+ </ Card >
93
+ < div className = 'flex flex-1 flex-col' />
94
+ </ div >
95
+ </ WithNavBanner >
96
96
) ;
97
97
} ;
0 commit comments