File tree 3 files changed +14
-15
lines changed
3 files changed +14
-15
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,6 @@ import { ClientOnly } from '~/components/common/ClientOnly'
14
14
import { PageDataHolder } from '~/components/common/PageHolder'
15
15
import { MdiClockOutline } from '~/components/icons/clock'
16
16
import { useSetHeaderMetaInfo } from '~/components/layout/header/internal/hooks'
17
- import { Divider } from '~/components/ui/divider'
18
17
import { FloatPopover } from '~/components/ui/float-popover'
19
18
import { Loading } from '~/components/ui/loading'
20
19
import { Markdown } from '~/components/ui/markdown'
@@ -116,7 +115,7 @@ const NotePage = memo(({ note }: { note: NoteModel }) => {
116
115
< TocAside
117
116
className = "sticky top-[120px] ml-4 mt-[120px]"
118
117
treeClassName = "max-h-[calc(100vh-6rem-4.5rem-300px)] h-[calc(100vh-6rem-4.5rem-300px)] min-h-[120px] relative"
119
- accessory = { NoteReadIndicator }
118
+ accessory = { ReadIndicator }
120
119
>
121
120
< NoteActionAside className = "translate-y-full" />
122
121
</ TocAside >
@@ -133,14 +132,6 @@ const NotePage = memo(({ note }: { note: NoteModel }) => {
133
132
</ Suspense >
134
133
)
135
134
} )
136
- const NoteReadIndicator = ( ) => {
137
- return (
138
- < li >
139
- < Divider />
140
- < ReadIndicator className = "text-sm" />
141
- </ li >
142
- )
143
- }
144
135
145
136
const NoteTitle = ( ) => {
146
137
const note = useNoteData ( )
Original file line number Diff line number Diff line change 1
- /* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
2
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
3
1
'use client'
4
2
5
3
import type { ElementType } from 'react'
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { atom, useAtom } from 'jotai'
4
4
import type { FC } from 'react'
5
5
import type { ITocItem } from './TocItem'
6
6
7
+ import { Divider } from '~/components/ui/divider'
7
8
import { RightToLeftTransitionView } from '~/components/ui/transition/RightToLeftTransitionView'
8
9
import { throttle } from '~/lib/_'
9
10
import { useArticleElement } from '~/providers/article/article-element-provider'
@@ -130,6 +131,12 @@ const TocTree: Component<
130
131
} ,
131
132
[ ] ,
132
133
)
134
+ const accessoryElement = useMemo ( ( ) => {
135
+ if ( ! accessory ) return null
136
+ return React . isValidElement ( accessory )
137
+ ? accessory
138
+ : React . createElement ( accessory as FC )
139
+ } , [ accessory ] )
133
140
return (
134
141
< ul
135
142
className = { clsxm (
@@ -150,9 +157,12 @@ const TocTree: Component<
150
157
/>
151
158
)
152
159
} ) }
153
- { React . isValidElement ( accessory )
154
- ? accessory
155
- : React . createElement ( accessory as FC ) }
160
+ { accessoryElement && (
161
+ < li >
162
+ { ! ! toc . length && < Divider /> }
163
+ { accessoryElement }
164
+ </ li >
165
+ ) }
156
166
</ ul >
157
167
)
158
168
}
You can’t perform that action at this time.
0 commit comments