mdbook-files 0.3.0

Preprocessor for mdbook which renders files from a directory as an interactive widget
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
window.addEventListener("load", (event) => {
    const uuids = {{ uuids | json_encode() }};
    function set_visible(uuid) {
        uuids.forEach((uuid) => {
            document.getElementById(`button-${uuid}`).classList.remove("active");
            document.getElementById(`file-${uuid}`).classList.remove("visible");
        });
        const button = document.getElementById(`button-${uuid}`).classList.add("active");
        const file = document.getElementById(`file-${uuid}`).classList.add("visible");
    }
    function add_hook(uuid) {
        const button = document.getElementById(`button-${uuid}`);
        button.addEventListener("click", (event) => set_visible(uuid));
    }
    uuids.forEach((uuid) => add_hook(uuid));
    set_visible({{ visible | json_encode() }});
});