feat: add anchor link for all headings

This commit is contained in:
Justineo
2022-05-26 19:16:47 +08:00
parent 9c98bc65e2
commit 0941d4e2f3
12 changed files with 347 additions and 17 deletions

4
plugins/global.js Normal file
View File

@@ -0,0 +1,4 @@
import Vue from 'vue'
import { IconLinkAlt } from 'dls-icons-vue'
Vue.component('icon-link', IconLinkAlt)

View File

@@ -29,6 +29,8 @@ export default ({ app }) => {
target = anchor.closest('tr')
} else if (app.router.currentRoute.name === 'changelog' && anchor.tagName === 'H2') {
target = anchor.closest('.version-item')
} else if (['H1', 'H2', 'H3', 'H4', 'H5', 'H6'].includes(anchor.tagName)) {
target = anchor
}
if (target) {