docs updates, add search to main page, fix redir bug
This commit is contained in:
parent
c1c061fbea
commit
22a9c0ddfc
4 changed files with 38 additions and 25 deletions
|
@ -126,13 +126,17 @@
|
|||
</button>`
|
||||
}
|
||||
|
||||
const redir = (id, term) => {
|
||||
window.location.href = {{.Site.BaseURL}} + `${id}#:~:text=${encodeURIComponent(term)}`
|
||||
}
|
||||
|
||||
const source = document.getElementById('search-bar')
|
||||
const results = document.getElementById("results-container")
|
||||
let term
|
||||
source.addEventListener("keyup", (e) => {
|
||||
if (e.key === "Enter") {
|
||||
const anchor = document.getElementsByClassName("result-card")[0]
|
||||
window.location.href = `${anchor.id}#:~:text=${encodeURIComponent(term)}`
|
||||
redir(anchor.id, term)
|
||||
}
|
||||
})
|
||||
source.addEventListener('input', (e) => {
|
||||
|
@ -163,9 +167,7 @@
|
|||
.join("\n")
|
||||
const anchors = document.getElementsByClassName("result-card");
|
||||
[...anchors].forEach(anchor => {
|
||||
anchor.onclick = () => {
|
||||
window.location.href = `${anchor.id}#:~:text=${encodeURIComponent(term)}`
|
||||
}
|
||||
anchor.onclick = () => redir(anchor.id, term)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue