Problem/Motivation
I have long book structures and would like to highlight the current page to help orient the user. While the Book Table of Contents block is otherwise good, it's missing an "active" class so I have no selector to use in CSS to make the item bold, for example.
For example
<li class="menu-item li-2" data-once="ul">
could be
<li class="menu-item li-2 active" data-once="ul">
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | Screenshot 2023-10-05 at 11.37.08 pm.png | 95.04 KB | kualee |
| #3 | Screenshot 2023-10-03 112325.png | 52.88 KB | adam_b |
Comments
Comment #2
bwong commentedThis may be a little harder to do because the Book module's function is used to generate the table of contents. Figuring out which element is the current page make require replicating and reworking that function. I am looking at what needs to be done to see what is required.
Comment #3
adam_b commentedThanks for responding, bwong
If it's any help, the core "Book navigation" block does provide this:
<li class="menu-item menu-item--active-trail li-2" data-once="ul">And just to give you an idea why it's needed, I've uploaded a partial screenshot of one book menu
Comment #5
bwong commentedFor some reason that does not follow through so I added my own. Probably need to go back and figure out how they did it but 1.12 does this. The class is book-blocks-active.
Comment #6
bwong commentedComment #7
kualeeHi @bwong thanks for this great little module. It helps me saving tons of hours in reinventing the wheels.

I would like to check about version 1.12 and the new class "book-blocks-active", is this meant to show on child page of a book?
I installed the module and dropped TOC block in my content but I cant see this new class in my menu at all.
Greatly appreciate your help!
Comment #8
bwong commented1.13 has the support in TOC. I had only implemented it in the Edit block TOC.
Comment #9
kualee@bwong you are a truly legend! It's all working as intended
Comment #10
adam_b commentedThanks bwong, that's a big help