Disco TOC for replies

Since Disco TOC is one of the theme components in the default list, I’m assuming this is an appropriate place to make a feature request.

It currently only works for the OP. I’d like to be able to add a TOC to a reply. Why?

When we do a webinar, we’ll announce it to the community with a post. After the webinar, we follow up with a reply in the same topic that contains the link to the recording and answers to all the questions that were asked during the webinar. We do this partly as a way to cover all the questions we couldn’t get to during the live session.

Those followup posts tend to get long and are typically sub-categorized by broad topic - perfect for a TOC (& actually the reason I installed the component).

Previously I’ve manually (and painfully) created a static TOC at the top of the reply post, but of course, once you’ve scrolled past it to the content, it’s no longer useful. Having the Disco TOC float alongside the content would be wonderful!

6 Likes

Interesting use case! I’ve done this in the past before too. Not sure if this will work in your case, but what we ended up doing is editing the first post to add the notes at the bottom, then replying to let everyone know about the edit. That way everything is neatly organized in the first post for posterity.

2 Likes

Perhaps its my long-ago days as a journalist, but I tend to be leery of editing history…

2 Likes

Yes, I totally get that. :slight_smile: But it can be useful for the long term, and Discourse provides the edit history for those who want full transparency. Here’s an example of a topic that we rewrote after a webinar, back when I was working for Namati. We even changed the language to be past tense, so a summary of the webinar and no longer an announcement. And removed all the logistical details on how to join and so on, because no longer relevant.

3 Likes

Update: The changes in this fork have been merged upstream, please use the official theme components instead

For anyone who wants to apply DiscoTOC in their replies, I did this part of the work in my own fork!
Now it can apply TOC to any post and it works fine, just like it does on the OP.
It seems that the official team doesn’t think it’s necessary to apply DiscoTOC in the replies, so I won’t open a pull request. But you can use my modified version!

https://github.com/Lhcfl/DiscoTOC-edited

4 Likes

TOC in the replies - yes please!!

2 Likes

A TOC for reply posts is possible - see here for the very out-of-the-box method.

4 Likes

For me as heavy iPad/iPhone user that solution is more like closed-in-box :stuck_out_tongue_winking_eye:

1 Like

hmmm, :thinking: I’m using an iPad Air with Safari iOS 16.6 and it works as expected and the same as Chrome. :woman_shrugging:t2:

2 Likes

Lhcfl/DiscoTOC-edited throws the error «Uncaught TypeError: ((intermediate value) || this[e]) is not a function» on inserting a table of contents.
Discourse 3.2.0.beta4-dev.

Oh, I‘ll look into it.


This is an automatic merge error that occurred when I synchronized with the upstream. Now I have fixed it.

hey @Lhc_fl

tried this fork, it is nice…
but seems, need to add this line to each posts/replies ?

<div data-theme-toc="true"> </div>

I already added all categories to the setting: auto TOC categories
seems this fork does not honor this setting ?

Would you be open to revisiting this? It would be great to have it as part of the officially maintained repo. And it wouldn’t / shouldn’t add any issues or instability.

My use-case is meetings, where we use an Event as the OP, and the minutes go in a new post somewhere below it. It would be great to have TOC available to be applied to minutes.

I would not want it to apply to all posts - that would get unpleasantly busy very fast!!!

6 Likes

I think with at least four users here in this topic and also sharing the use case, it’s worth it to reconsider.

5 Likes

For those who care about applying TOC to replies - The ability to apply TOC to replies has been merged into the official component. It is a setting that is off by default.

12 Likes

Looking forward to seeing this deployed on my site. :innocent:

4 Likes

As this is a theme component, you should be able to update it from your /admin/customize/components page. :crossed_fingers:

Though if you encounter any issues let me know and we can smooth anything out. :slight_smile:

6 Likes

This works fantastic - great job Linca! :purple_heart:

Using this on my local instance and it’s great. Thank you! Now I don’t have to make new topics in my notebook when I want a TOC for a post! :hugs:

9 Likes

After using the new functionality a bit (bravo by the way!), I was wrong about this - as you can specify how many headings before a TOC is activated, it simply isn’t a problem.

However, inserting the TOC code is quite a pain.

Would you be open to changing this so that with auto specified categories and tags reply TOCs are also turned on? Or making that an option?

2 Likes

How do you insert it? For me, clicking a button in the composer isn’t that complicated.

2 Likes