Skip to content

Commit cbf7ef1

Browse files
committed
contraversial: Add #
1 parent ef307d9 commit cbf7ef1

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

_layouts/base.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@
6666
line-height: 1.5;
6767
}
6868
pre code { background: transparent; padding: 0; }
69+
main :is(h2,h3,h4,h5,h6)[id] > a { color: inherit; text-decoration: none; }
70+
main :is(h2,h3,h4,h5,h6)[id] > a:hover::after { content: " #"; color: #bbb; }
6971
</style>
7072
{%- if page.math -%}
7173
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.21/dist/katex.min.css" crossorigin="anonymous">
@@ -114,6 +116,7 @@
114116
</footer>
115117
</center>
116118
</div>
119+
<script>document.querySelectorAll('main :is(h2,h3,h4,h5,h6)[id]').forEach(h=>h.innerHTML=`<a href="#${h.id}">${h.innerHTML}</a>`);</script>
117120
<script>document.addEventListener('keydown',e=>{const as=[...document.querySelectorAll('[aria-label="Post navigation"] a')];if(e.key==='ArrowLeft'){const a=as.find(a=>a.textContent.includes('<'));if(a)location.href=a.href;}if(e.key==='ArrowRight'){const a=as.find(a=>a.textContent.includes('>'));if(a)location.href=a.href;}});</script>
118121
</body>
119122
</html>

0 commit comments

Comments
 (0)