Skip to content

Commit b9fef6f

Browse files
fix: anchor links (#1083)
* chore: bump docusaurus v2.0.0-beta.7 * fix: anchor link is not triggering on the first page load
1 parent 660dfcb commit b9fef6f

File tree

3 files changed

+1225
-1150
lines changed

3 files changed

+1225
-1150
lines changed

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@
1414
"fetch-sponsors": "node scripts/fetch-sponsors.js"
1515
},
1616
"dependencies": {
17-
"@docusaurus/core": "^2.0.0-beta.6",
18-
"@docusaurus/plugin-google-analytics": "^2.0.0-beta.6",
19-
"@docusaurus/preset-classic": "2.0.0-beta.6",
20-
"@docusaurus/remark-plugin-npm2yarn": "^2.0.0-beta.6",
17+
"@docusaurus/core": "2.0.0-beta.7",
18+
"@docusaurus/plugin-google-analytics": "2.0.0-beta.7",
19+
"@docusaurus/preset-classic": "2.0.0-beta.7",
20+
"@docusaurus/remark-plugin-npm2yarn": "2.0.0-beta.7",
2121
"@octokit/graphql": "^4.8.0",
2222
"@react-navigation/core": "^6.0.1",
23-
"classnames": "^2.2.6",
23+
"classnames": "^2.3.1",
2424
"docsearch.js": "^2.6.3",
2525
"escape-html": "^1.0.3",
2626
"mkdirp": "^1.0.4",
2727
"netlify-plugin-cache": "^1.0.3",
2828
"prism-react-renderer": "^1.1.1",
29-
"react": "^17.0.1",
30-
"react-dom": "^17.0.1",
29+
"react": "^17.0.2",
30+
"react-dom": "^17.0.2",
3131
"react-simple-code-editor": "^0.11.0"
3232
},
3333
"browserslist": {

src/pages/layouts/DocPage.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,16 @@ function DocPage(props) {
1818
});
1919

2020
React.useEffect(() => {
21+
2122
initializeSnackObservers();
23+
//note: @eriveltonelias
24+
// currently on docusaurus v2.0.0-beta.7 when the page loads on the first time
25+
// the anchor links is not working as expected.
26+
const hashId = window.location.hash;
27+
const element = document.getElementById(hashId.split('#').join(''));
28+
if (element) {
29+
element.scrollIntoView();
30+
}
2231

2332
return () => {
2433
removeSnackObservers();

0 commit comments

Comments
 (0)