mirror of
https://mau.dev/andreijiroh-dev/website.git
synced 2025-06-24 13:26:11 +00:00
chore(global): update deps and work for Read the Docs Addons support
also sync the overriden templates against mkdocs-material upstream Signed-off-by: Andrei Jiroh Halili <ajhalili2006@andreijiroh.dev>
This commit is contained in:
parent
e5048e6f0f
commit
e440ee780d
11 changed files with 279 additions and 205 deletions
42
markdown/assets/javascripts/rtd.js
Normal file
42
markdown/assets/javascripts/rtd.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
|
||||
/* RTD Search integration */
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
// Trigger Read the Docs' search addon instead of Material MkDocs default
|
||||
document.querySelector(".md-search__input").addEventListener("focus", (e) => {
|
||||
const event = new CustomEvent("readthedocs-search-show");
|
||||
document.dispatchEvent(event);
|
||||
});
|
||||
});
|
||||
|
||||
/* RTD version selector */
|
||||
// Use CustomEvent to generate the version selector
|
||||
document.addEventListener(
|
||||
"readthedocs-addons-data-ready",
|
||||
function (event) {
|
||||
const config = event.detail.data();
|
||||
const versioning = `
|
||||
<div class="md-version">
|
||||
<button class="md-version__current" aria-label="Select version">
|
||||
${config.versions.current.slug}
|
||||
</button>
|
||||
|
||||
<ul class="md-version__list">
|
||||
${ config.versions.active.map(
|
||||
(version) => `
|
||||
<li class="md-version__item">
|
||||
<a href="${ version.urls.documentation }" class="md-version__link">
|
||||
${ version.slug }
|
||||
</a>
|
||||
</li>`).join("\n")}
|
||||
</ul>
|
||||
</div>`;
|
||||
|
||||
// Check if we already added versions and remove them if so.
|
||||
// This happens when using the "Instant loading" feature.
|
||||
// See https://squidfunk.github.io/mkdocs-material/setup/setting-up-navigation/#instant-loading
|
||||
const currentVersions = document.querySelector(".md-version");
|
||||
if (currentVersions !== null) {
|
||||
currentVersions.remove();
|
||||
}
|
||||
document.querySelector(".md-header__topic").insertAdjacentHTML("beforeend", versioning);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue