File tree 3 files changed +6
-5
lines changed
3 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -18,14 +18,15 @@ export const Sidebar: FC<{
18
18
}
19
19
20
20
useEffect ( ( ) => {
21
- setHash ( location . hash )
21
+ setHash ( decodeURIComponent ( location . hash ) )
22
22
const onHashChange = ( ) => {
23
- setHash ( location . hash )
23
+ const decodedHash = decodeURIComponent ( location . hash )
24
+ setHash ( decodedHash )
24
25
25
26
// Don't change scroll position when the hashchange is triggered click, that's bad user experience
26
27
if ( location . hash && ! sidebarItemClicked ) {
27
28
const el : HTMLAnchorElement | null = document . querySelector (
28
- `.sidebar .menu_item[href="${ location . hash } "]`
29
+ `.sidebar .menu_item[href="${ decodedHash } "]`
29
30
)
30
31
if ( el ) {
31
32
if ( sidebarRef . current ) {
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ export const ANCHOR_ICON = `<svg xmlns="http://www.w3.org/2000/svg" aria-hidden=
18
18
`
19
19
20
20
export function scrollToHash ( hash : string ) {
21
- const el = document . querySelector ( hash ) as HTMLDivElement
21
+ const el = document . querySelector ( decodeURIComponent ( hash ) ) as HTMLDivElement
22
22
if ( el ) {
23
23
window . scrollTo ( {
24
24
top : el . offsetTop - 60 ,
Original file line number Diff line number Diff line change @@ -6,6 +6,6 @@ this is a test
6
6
7
7
some text
8
8
9
- ### heading 3
9
+ ### 中文
10
10
11
11
some other text
You can’t perform that action at this time.
0 commit comments