feat: add hash anchor to changelog versions

This commit is contained in:
Justineo
2021-10-21 14:40:06 +08:00
parent e7f935b652
commit 6112f81c46
2 changed files with 43 additions and 3 deletions

View File

@@ -8,7 +8,7 @@ function clearTarget () {
delete target.dataset.target
}
export default ({ app }) => {
export default ({ app, route }) => {
document.documentElement.addEventListener('click', clearTarget)
app.router.afterEach(to => {
@@ -24,6 +24,11 @@ export default ({ app }) => {
if (anchor.tagName === 'CODE') {
target = anchor.closest('tr')
} else if (route.name === 'changelog' && anchor.tagName === 'H2') {
target = anchor.closest('.version-item')
}
if (target) {
target.dataset.target = ''
}
}, 0)