File tree 3 files changed +6
-9
lines changed
3 files changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,9 @@ export const Content = defineComponent({
5
5
name : 'VitePressContent' ,
6
6
setup ( ) {
7
7
const route = useRoute ( )
8
- return ( ) => ( route . component ? h ( route . component ) : null )
8
+ return ( ) =>
9
+ h ( 'div' , { style : { position : 'relative' } } , [
10
+ route . component ? h ( route . component ) : null
11
+ ] )
9
12
}
10
13
} )
Original file line number Diff line number Diff line change @@ -172,13 +172,11 @@ export function useRoute(): Route {
172
172
}
173
173
174
174
function scrollTo ( el : HTMLElement , hash : string , smooth = false ) {
175
- const nav = document . querySelector ( '.nav-bar' )
176
- const pageOffset = nav ? ( nav as HTMLElement ) . offsetHeight : 0
177
175
const target = el . classList . contains ( '.header-anchor' )
178
176
? el
179
177
: document . querySelector ( decodeURIComponent ( hash ) )
180
178
if ( target ) {
181
- const targetTop = ( target as HTMLElement ) . offsetTop - pageOffset - 15
179
+ const targetTop = ( target as HTMLElement ) . offsetTop
182
180
// only smooth scroll if distance is smaller than screen height.
183
181
if ( ! smooth || Math . abs ( targetTop - window . scrollY ) > window . innerHeight ) {
184
182
window . scrollTo ( 0 , targetTop )
Original file line number Diff line number Diff line change @@ -8,12 +8,8 @@ import NextAndPrevLinks from './NextAndPrevLinks.vue'
8
8
<div class =" container" >
9
9
<slot name =" top" />
10
10
11
- <div class =" content" >
12
- <Content />
13
- </div >
14
-
11
+ <Content class =" content" />
15
12
<PageFooter />
16
-
17
13
<NextAndPrevLinks />
18
14
19
15
<slot name =" bottom" />
You can’t perform that action at this time.
0 commit comments