-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
Attention: do not use for confident content (unencrypted), just appropriate for restricted content (block for end-user)
Workaround 1 (failed)
Add the following lines to mkdocs.yml
:
- encryptcontent:
encrypted_something:
#md-search: [div, class] # Hide's Search v1 (Not Working)
#md-search__inner : [div, class] # Hide's Search v2 (Not Working)
#md-search__output: [div, class] # Hide's Search v3 (Not Working)
#md-search-result: [div, class] # Hide's Search v3 (Not Working)
Workaround 2 (worked)
Adjust the following lines for mkdocs.yml
, if you want the search to not be encrypted just hidden
- encryptcontent:
search_index: clear # Workaround with Hidden Button
Add a script to mkdocs (material):
extra_javascript:
- javascripts/hidden-search.js
Hide the search field when on locked page
document.addEventListener("DOMContentLoaded", () => {
const searchElement = document.querySelector(".md-search");
// Function to check for mkdocs-decrypt-form and toggle .md-search visibility
const checkDecryptedContent = () => {
const decryptedContent = document.getElementById("mkdocs-decrypt-form")
if (decryptedContent) {
// Hide the .md-search element if mkdocs-decrypt-form is found
searchElement.style.display = "none";
} else {
// Show the .md-search element if mkdocs-decrypt-form is not found
searchElement.style.display = "";
}
console.log("Encrypted content check complete.");
};
// Initial check
checkDecryptedContent();
// Repeat the check with quadratic increasing interval over time
let count = 1;
let interval = 500;
setInterval(() => checkDecryptedContent(), interval = 500 * count++ ** 2);
});
Metadata
Metadata
Assignees
Labels
No labels