We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8263439 commit fd84f36Copy full SHA for fd84f36
1 file changed
theme/toc.js.hbs
@@ -10,7 +10,9 @@ class MDBookSidebarScrollbox extends HTMLElement {
10
connectedCallback() {
11
// Modify TOC to support external links
12
var toc = '{{#toc}}{{/toc}}';
13
- toc = toc.replace(/<div>([^$<>]*)\$\$external:([^$<>]*)\$\$<\/div>/g, '<a class="external-link" href="$2">$1</a>')
+ // Handle both old mdbook (<div>) and new mdbook 0.5 (<span>) formats
14
+ // External links open in new tab with external link icon
15
+ toc = toc.replace(/<(div|span)>([^$<>]*)\$\$external:([^$<>]*)\$\$<\/(div|span)>/g, '<a class="external-link" href="$3" target="_blank" rel="noopener noreferrer">$2 ↗</a>')
16
this.innerHTML = toc
17
// Set the current, active page, and reveal it if it's hidden
18
let current_page = document.location.href.toString();
0 commit comments