fix notes number on PageView
This commit is contained in:
@@ -22,17 +22,18 @@ export default {
|
||||
const links = this.$el.querySelectorAll('.page-wrapper a')
|
||||
links.forEach((link, i) => {
|
||||
const number = parseInt(link.hash.replace('#', ''))
|
||||
if (!isNaN(number)) {
|
||||
if (!isNaN(number) && this.page.notes.find(note => note.number === number)) {
|
||||
link.classList.add('page-footnote-link')
|
||||
link.id = `footnote-${this.slug}-${number}`
|
||||
link.setAttribute('href', 'javascript:;')
|
||||
link.dataset.number = number
|
||||
link.textContent = i + 1
|
||||
if (link.parentElement.nodeName === 'SUP') {
|
||||
link.parentElement.replaceWith(link)
|
||||
}
|
||||
link.onclick = this.onFootnoteLinkClick
|
||||
|
||||
this.addFootnoteContent(link, i)
|
||||
this.addFootnoteContent(link, number)
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -41,7 +42,7 @@ export default {
|
||||
const noteContainer = document.createElement('DIV')
|
||||
noteContainer.classList.add('page-footnote-content')
|
||||
noteContainer.id = link.id + '-content'
|
||||
noteContainer.innerHTML = this.page.notes[i].content
|
||||
noteContainer.innerHTML = this.page.notes.find(note => note.number === i).content
|
||||
link.insertAdjacentElement('afterend', noteContainer)
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user