Closed mrpotatoes closed 4 years ago
This is the cheapest way to do it (for modern browsers) and get non-link items to work.
diff --git a/src/index.js b/src/index.js
index ddeba40..56d3205 100644
--- a/src/index.js
+++ b/src/index.js
@@ -59,8 +59,13 @@ document.addEventListener(
)
document.addEventListener('DOMContentLoaded', () => {
- document.querySelector('.sidebar-nav').addEventListener('click',
+ document.querySelector('.sidebar-nav').addEventListener(
+ 'click',
e => {
+ if (e.target.tagName === 'P') {
+ e.target.parentElement.classList.toggle('open')
+ }
+
if (e.target.tagName === 'A') {
const elp = e.target.parentElement
if (elp.tagName === 'LI') {
@@ -84,4 +89,4 @@ document.addEventListener('DOMContentLoaded', () => {
},
true
)
-})
+})
\ No newline at end of file
If the parent in the markdown doesn't have a link it doesn't work.
Given this
sidebar.md
codeIt will not be clickable to open. I must make the parent be a link ala: