File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed
Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ // Use CustomEvent to generate the version selector
2+ document . addEventListener ( "readthedocs-addons-data-ready" , function ( event ) {
3+ const config = event . detail . data ( ) ;
4+ const versioning = `
5+ <div class="md-version">
6+ <button class="md-version__current" aria-label="Select version">
7+ ${ config . versions . current . slug }
8+ </button>
9+
10+ <ul class="md-version__list">
11+ ${ config . versions . active
12+ . map (
13+ ( version ) => `
14+ <li class="md-version__item">
15+ <a href="${ version . urls . documentation } " class="md-version__link">
16+ ${ version . slug }
17+ </a>
18+ </li>` ,
19+ )
20+ . join ( "\n" ) }
21+ </ul>
22+ </div>` ;
23+
24+ // Check if we already added versions and remove them if so.
25+ // This happens when using the "Instant loading" feature.
26+ // See https://squidfunk.github.io/mkdocs-material/setup/setting-up-navigation/#instant-loading
27+ const currentVersions = document . querySelector ( ".md-version" ) ;
28+ if ( currentVersions !== null ) {
29+ currentVersions . remove ( ) ;
30+ }
31+ document
32+ . querySelector ( ".md-header__topic" )
33+ . insertAdjacentHTML ( "beforeend" , versioning ) ;
34+ } ) ;
Original file line number Diff line number Diff line change 1+ {% extends "base.html" %}
2+
3+ {% block site_meta %}
4+ {{ super() }}
5+ < meta name ="readthedocs-addons-api-version " content ="1 " />
6+ {% endblock %}
You can’t perform that action at this time.
0 commit comments