-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jobber med hash-lenker. Går bort fra å bruke gatsby-Link for hash-len…
…ker da det ga litt rar oppførsel og ikke er anbefalt av gatsby måtte implementere litt custom greier da dette ikke ser ut til å virke ut av boksen med gatsby gatsbyjs/gatsby#21120 https://codingcat.dev/blog/anchor-links-from-sanity-in-gatsby/#sanityio https://stackoverflow.com/questions/24665602/scrollintoview-scrolls-just-too-far trodde egentlig denne PR'en skulle fikse det, men ser ikke at det funker..? gatsbyjs/gatsby#24306
- Loading branch information
Showing
19 changed files
with
81 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
!*.json | ||
!gatsby*.js | ||
!gatsby*.ts | ||
!gatsby-node-files | ||
!gatsby-utils | ||
!nginx-server-rules.conf | ||
!plugins | ||
!src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
import DefaultLayout from './src/utils/wrapPageElement'; | ||
import { GatsbyBrowser } from 'gatsby'; | ||
import { anchorScroll } from './gatsby-utils/anchorScroll'; | ||
|
||
export const onRouteUpdate: GatsbyBrowser['onRouteUpdate'] = (props) => { | ||
anchorScroll(props.location); | ||
return true; | ||
}; | ||
|
||
export const shouldUpdateScroll: GatsbyBrowser['shouldUpdateScroll'] = (props) => { | ||
anchorScroll(props.routerProps.location); | ||
return true; | ||
}; | ||
|
||
export const wrapPageElement = DefaultLayout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export function anchorScroll(location: Location) { | ||
setTimeout(() => { | ||
const hash = location.hash.replace('#', ''); | ||
const element = document.getElementById(hash); | ||
element?.scrollIntoView(); | ||
}, 0); | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
src/components/BlockContent/GroupMarkup.tsx → .../BlockContent/GroupMarkup/GroupMarkup.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/components/BlockContent/GroupMarkup/useGroupMarkupAriaProps.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Group } from '../../../utils/richTextUtils/richTextTypes'; | ||
|
||
export function useGroupMarkupAriaProps(group: Group) { | ||
const id = group.blockConfig?.id; | ||
const headerId = id + '-header'; | ||
|
||
return { | ||
regionProps: { | ||
id: id, | ||
tabIndex: -1, | ||
'aria-labelledby': headerId, | ||
}, | ||
headerProps: { | ||
id: headerId, | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters