File tree Expand file tree Collapse file tree 5 files changed +22
-2
lines changed
package-code/[[org]]/[packageName]/v/[version] Expand file tree Collapse file tree 5 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ definePageMeta({
1313 ' /package/code/:packageName/v/:version/:filePath(.*)?' ,
1414 // '/code/@:org?/:packageName/v/:version/:filePath(.*)?',
1515 ],
16+ scrollMargin: 160 ,
1617})
1718
1819const route = useRoute (' code' )
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ definePageMeta({
77 name: ' docs' ,
88 path: ' /package-docs/:path+' ,
99 alias: [' /package/docs/:path+' , ' /docs/:path+' ],
10+ scrollMargin: 180 ,
1011})
1112
1213const route = useRoute (' docs' )
Original file line number Diff line number Diff line change 22// stub page to help with paths
33definePageMeta ({
44 name: ' package' ,
5+ scrollMargin: 150 ,
56})
67 </script >
78
Original file line number Diff line number Diff line change @@ -3,13 +3,18 @@ import type { RouterConfig } from 'nuxt/schema'
33export default {
44 scrollBehavior ( to , _from , savedPosition ) {
55 // If the browser has a saved position (e.g. back/forward navigation), restore it
6+
67 if ( savedPosition ) {
78 return savedPosition
89 }
9-
1010 // If navigating to a hash anchor, scroll to it
1111 if ( to . hash ) {
12- return { el : to . hash , behavior : 'smooth' }
12+ const { scrollMargin } = to . meta
13+ return {
14+ el : to . hash ,
15+ behavior : 'smooth' ,
16+ top : typeof scrollMargin == 'number' ? scrollMargin : 70 ,
17+ }
1318 }
1419
1520 // Otherwise, scroll to the top of the page
Original file line number Diff line number Diff line change 1+ import '#app'
2+ import '#vue-router'
13export * from './icon'
24export * from './navigation'
5+
6+ declare module '#app' {
7+ interface PageMeta {
8+ /**
9+ * top margin in pixels for scrolling to an element
10+ * @default 70
11+ */
12+ scrollMargin ?: number
13+ }
14+ }
You can’t perform that action at this time.
0 commit comments