DiscoTOC - automatic table of contents

I might be missing something obvious (as it happens often). When I add a TOC I lose access to the top right wrench menu, so I cannot pin/unpin a topic (using for some long event pages).

So the only way to change is to temporarily remove the TOC to access the button.?

With Disco:

Without Disco:

3 Likes

Yes, this is by design. In this case you can use the wrench on the topic menu, at the bottom.

4 Likes

My wrench menus are different. The right side one at top right (which disappears with DiscoTOC) shows:

and my bottom topic one:

So I have no access to the Pin topic settings there (unless I am looking at wrong wrench)

1 Like

Yes, you are looking at the wrong wrench. :wink: The second screenshot you provided is of the post admin wrench, at the bottom of every post. There is another admin wrench in the topic menu at the very bottom, before suggested topics.

3 Likes

Oi! I had the wrong wrench. Now I got it, many apologies, all is good

3 Likes

I seem to be missing the anchor links next to the headings, which allowed me to link to a specific section directly, for instance in this topic, like described in the start post:

Is this me or did this functionality disappear?

2 Likes

They should be there? I’m currently on my phone, but I grabbed this one by long-pressing on the gap to the side of the heading:

https://meta.discourse.org/t/discotoc-automatic-table-of-contents/111143#how-does-it-work-3

2 Likes

Yes, that topic has those anchor links, but that’s a topic that does not have the DiscoTOC.

But this topic has a TOC and does not have anchors: Beginner's guide to using Discourse Themes and this one does not have anchors either DiscourseConnect - Official Single-Sign-On for Discourse (sso)

EDIT Hmm…this topic does have anchors: Discourse API Documentation

3 Likes

Ah, I can explain. The topic you linked has html headings (<h3>, <h4> and so on) and initially the TOC component had its own logic for adding heading anchors. However, since then, core added automatic anchors and recently I removed the custom anchor login in the theme component. However, core’s anchor feature only works for Markdown headings (using ###).

So that’s the OP here has anchors, but the linked guide doesn’t.

We probably should update that guide to use Markdown instead of HTML @JammyDodger.

5 Likes

Ah! That explains things perfectly, thanks Penar!!

4 Likes

I was clearly not paying enough attention yesterday. :slight_smile: I have now swopped in Markdown headers for the two example topics. :+1:

2 Likes

Nice component, the # links created for the headings are very neat too.

Is there a way to move the icon link as pictured in the screenshot?

Right now it hovers over the left, in between the user icon and heading text (see below)

Screen Shot 2022-07-13 at 7.27.19 PM

Edit:

A suggestion if I may.

By nature, posts with TOC will be long. When the Google crawler sees the page it doesn’t see the TOC nor those nifty links to different parts of the page. Perhaps on the crawler version we can have those links show up for each heading/sub-heading.

1 Like

Hi there, I wonder if there is a way to bulk apply the TOC to topics? We just installed the TOC component recently and now having to manually apply it to old topics is a bit tedious :smiling_face_with_tear:

2 Likes

I’ll double-check, but I don’t think that’s currently possible? Though I do sympathise with the manual edits. :slight_smile: How many have you got left to do?

3 Likes

I don’t think we have a whole lot of them at the moment, though it’d be great if the team could consider implementing this feature in a future release :crossed_fingers:

2 Likes

It was such a great idea @albert_vu that it’s now been added: :slightly_smiling_face::+1:

9 Likes

Great :smile: so I guess that I’d need to update the theme-component from my end?

2 Likes

If you check, I’ll think you’ll find it’s already been done. :slightly_smiling_face::+1:

But for anyone else wanting the swish new functionality, you can update the theme component from its customise page:

2 Likes

Hmmm, just thought of a scenario where a user doesn’t want to have a TOC in their topic, is there a way to revert that? :thinking:

1 Like

I like the tag element of it, so you could have a specific tag for TOC, and then remove it again if one is not desired?

2 Likes