Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logo over TOC #2490

Open
MaxThom opened this issue Nov 20, 2024 · 2 comments
Open

Logo over TOC #2490

MaxThom opened this issue Nov 20, 2024 · 2 comments
Labels
C-question Category: A question on how to do something

Comments

@MaxThom
Copy link

MaxThom commented Nov 20, 2024

Question

Hi,

I have a mdbook where I modified the index.hbs to add a logo above the TOC:
Image

I have upgraded to the latest version v0.4.42 and readjusted the index.hbs and all the theme contents and since then I can't get my logo working. The TOC is always over it. I have tried a bunch of things such as modifying the css of the scrollbar to relative which work, but then I loose the scrollbar:
Image

Snippet of my added div:

        <nav id="sidebar" class="sidebar" aria-label="Table of contents">
            <div class="logo">
       		   <img alt="{{ book_title }}" width=148px src="{{ path_to_root }}logos/mir_alpha.png">
            </div>
            <!-- populated by js -->
            <mdbook-sidebar-scrollbox class="sidebar-scrollbox"></mdbook-sidebar-scrollbox>
            <noscript>
                <iframe class="sidebar-iframe-outer" src="{{ path_to_root }}toc.html"></iframe>
            </noscript>

            <div id="sidebar-resize-handle" class="sidebar-resize-handle">
                <div class="sidebar-resize-indicator"></div>
            </div>
        </nav>

I tried adjusting the scrollbar css to relative, or top padding which work, but something else break. If I had the div inside the mdbook-sidebar-scrollbox, the logo does below the TOC.

Any idea on how to achieve this? Thank you!

Version

v0.4.42
@MaxThom MaxThom added the C-question Category: A question on how to do something label Nov 20, 2024
@ehuss
Copy link
Contributor

ehuss commented Nov 20, 2024

@notriddle Can you help here?

@notriddle
Copy link
Contributor

The simplest way to fix this, without changing anything else, would be to modify toc.js.hbs:

this.innerHTML = '{{#toc}}{{/toc}}';

If you insert your <div> before the {{#toc}} placeholder, it will appear at the top of the sidebar, within the scrollbox.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-question Category: A question on how to do something
Projects
None yet
Development

No branches or pull requests

3 participants