Skip to content
This repository was archived by the owner on Mar 4, 2024. It is now read-only.

Commit e65788b

Browse files
committed
Use hash for expanding.
1 parent 609e149 commit e65788b

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

src/components/GenerateBlocks.tsx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ const GenerateBlocks = ({
6262
markdownParsingOptions?: MarkdownToJSX.Options
6363
}) => {
6464

65-
// Anchor fixture
66-
useAnchor();
67-
6865
return (
6966
<>
7067
{blocks &&
@@ -83,18 +80,13 @@ const GenerateBlocks = ({
8380
})}
8481
</>
8582
)
86-
};
87-
88-
export { GenerateBlocks, supportedTypes }
89-
90-
const useAnchor = () => {
91-
9283
}
9384

85+
export { GenerateBlocks, supportedTypes }
9486

9587
const Anchor = styled.a`
96-
position: relative;
97-
display: none;
98-
visibility: hidden;
88+
position: relative;
89+
display: none;
90+
visibility: hidden;
9991
height: 0;
100-
`;
92+
`

src/utils/useHashSelected.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { useEffect, useMemo, useState } from "react"
1+
import { useEffect, useMemo, useState } from 'react'
22

33
export const useHashSelected = (targetHash?: string) => {
44
const [hash, setHash] = useState<string>()
55

6-
const updateHash = () => setHash(getHash());
6+
const updateHash = () => setHash(getHash())
77

88
useEffect(() => {
99
updateHash()
@@ -17,9 +17,9 @@ export const useHashSelected = (targetHash?: string) => {
1717
if (!targetHash) {
1818
return false
1919
}
20-
20+
2121
const firstPart = hash?.split('__')[0]
22-
const result = "#" + targetHash === firstPart
22+
const result = '#' + targetHash === firstPart
2323
return result
2424
}, [hash, targetHash])
2525
}

0 commit comments

Comments
 (0)