Coder Social home page Coder Social logo

Comments (7)

alex-shpak avatar alex-shpak commented on July 20, 2024

Hi!
There was previous discussion on foldable menu (#32)
I didn't find nice solution yet, since I try to keep theme as JS-free as possible, but I have it in mind.

from hugo-book.

kchen0x avatar kchen0x commented on July 20, 2024

Wait for your enhancement~~

from hugo-book.

alex-shpak avatar alex-shpak commented on July 20, 2024

I added some 'experimental' bookCollapseSection parameter per page, settings it in section will cause file-tree menu to not render nested section unless visited. Handled at HTML generation time.

image

image

Would be nice if you can test it

from hugo-book.

kchen0x avatar kchen0x commented on July 20, 2024

what if I use menu/index.md to organize my sidebar menu?

from hugo-book.

alex-shpak avatar alex-shpak commented on July 20, 2024

Hi!
That one would work only for file-tree menu, unfortunately.
Bundle menu will need something more complex 🤔

from hugo-book.

alex-shpak avatar alex-shpak commented on July 20, 2024

Hi again!
I tried to find nice solution for a while, unfortunately it seems like I didn't find one. So I mark as wontfix.
I think these days filetree menu is much more powerful and we also got hugo native menus now.

I would recommend to switch to filetree menu or make JS script to fold menu and inject it via one of inject partials.

from hugo-book.

nianjiang avatar nianjiang commented on July 20, 2024

As alex-shpak suggested, I used js in inject partials to un-collapse the menu.


The related code:
Find the id from html:

<li>
    <input type="checkbox" id="section-2d21464784c99358edd6d2b29e92ed6f" class="toggle" checked="">
    <label for="section-.." class="flex justify-between">
      <a href=".." class="active">..</a>
    </label>

Add js in themes/hugo-book/layouts/partials/docs/inject/footer.html

<script type="text/javascript">
    //Open menu after page loaded.
    document.getElementById("section-2d21464784c99358edd6d2b29e92ed6f").click();
</script>

from hugo-book.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.