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

Commit 16a7816

Browse files
committed
feat: smooth scroll (#49)
1 parent d6bfae3 commit 16a7816

File tree

6 files changed

+39
-3
lines changed

6 files changed

+39
-3
lines changed

docs/config/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,3 +411,18 @@ You can set this option to `SimplePagination` to enable another out-of-box
411411
You can also wirte a custom pagination component and register it as a global component. then pass its
412412
name to this option.
413413

414+
## smoothScroll
415+
416+
- Type: `boolean`
417+
- Default: `false`
418+
419+
The `themeConfig.smoothScroll` option allows you to enable smooth scrolling.
420+
421+
```JavaScript
422+
// .vuepress/config.js
423+
module.exports = {
424+
themeConfig: {
425+
smoothScroll: true
426+
}
427+
}
428+
```

example/.vuepress/config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ module.exports = {
151151
*/
152152
newsletter: {
153153
endpoint: 'https://billyyyyy3320.us4.list-manage.com/subscribe/post?u=4905113ee00d8210c2004e038&id=bd18d40138'
154-
}
154+
},
155155
/**
156156
* Ref: https://vuepress-theme-blog.ulivz.com/#modifyblogpluginoptions
157157
*/
@@ -196,5 +196,10 @@ module.exports = {
196196
*/
197197

198198
// paginationComponent: 'SimplePagination'
199+
200+
/**
201+
* Ref: https://vuepress-theme-blog.ulivz.com/#smoothscroll
202+
*/
203+
smoothScroll:true
199204
},
200205
}

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ module.exports = themeConfig => {
7373
/**
7474
* Integrate plugins
7575
*/
76+
77+
const enableSmoothScroll = themeConfig.smoothScroll === true
78+
7679
const plugins = [
7780
'@vuepress/plugin-nprogress',
7881
['@vuepress/medium-zoom', true],
@@ -83,6 +86,7 @@ module.exports = themeConfig => {
8386
},
8487
],
8588
['@vuepress/blog', blogPluginOptions],
89+
['smooth-scroll', enableSmoothScroll],
8690
]
8791

8892
/**

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
"@vuepress/plugin-search": "1.0.0",
5050
"dayjs": "^1.8.19",
5151
"remove-markdown": "^0.3.0",
52-
"vue-feather-icons": "^4.21.0"
52+
"vue-feather-icons": "^4.21.0",
53+
"vuepress-plugin-smooth-scroll": "^0.0.9"
5354
},
5455
"devDependencies": {
5556
"babel-eslint": "^10.0.3",

test/__snapshots__/config.spec.js.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ Object {
6464
},
6565
},
6666
],
67+
Array [
68+
"smooth-scroll",
69+
false,
70+
],
6771
],
6872
}
6973
`;

yarn.lock

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9383,7 +9383,7 @@ slice-ansi@^2.1.0:
93839383
astral-regex "^1.0.0"
93849384
is-fullwidth-code-point "^2.0.0"
93859385

9386-
smoothscroll-polyfill@^0.4.3:
9386+
smoothscroll-polyfill@^0.4.3, smoothscroll-polyfill@^0.4.4:
93879387
version "0.4.4"
93889388
resolved "https://registry.yarnpkg.com/smoothscroll-polyfill/-/smoothscroll-polyfill-0.4.4.tgz#3a259131dc6930e6ca80003e1cb03b603b69abf8"
93899389
integrity sha512-TK5ZA9U5RqCwMpfoMq/l1mrH0JAR7y7KRvOBx0n2869aLxch+gT9GhN3yUfjiw+d/DiF1mKo14+hd62JyMmoBg==
@@ -10753,6 +10753,13 @@ vuepress-plugin-smooth-scroll@^0.0.3:
1075310753
dependencies:
1075410754
smoothscroll-polyfill "^0.4.3"
1075510755

10756+
vuepress-plugin-smooth-scroll@^0.0.9:
10757+
version "0.0.9"
10758+
resolved "https://registry.yarnpkg.com/vuepress-plugin-smooth-scroll/-/vuepress-plugin-smooth-scroll-0.0.9.tgz#6c5d01db60def3d7b976b53404e56b97da9e8f39"
10759+
integrity sha512-UXX+HLZO1NKVwyiOJlj0smh8F9dKnwybjEi7w/Mj9EYLhKrNYr5uXs+N+OTt8VwKCn3f0vZ1XAwFIjsPlD7GJA==
10760+
dependencies:
10761+
smoothscroll-polyfill "^0.4.4"
10762+
1075610763
vuepress@^1.2.0:
1075710764
version "1.2.0"
1075810765
resolved "https://registry.yarnpkg.com/vuepress/-/vuepress-1.2.0.tgz#2f2cdf337ad40a3e4866dfd33e97b840db386af7"

0 commit comments

Comments
 (0)