DiscoTOC - automatic table of contents

I checked it with non-Latin symbols like Cyrillic and it’s not working. When I copy the url of the subheader and try to follow the link - the TOC is not working (the page opens, but doesn’t move to the subheader). How can it be solved?

1 Like

Another question. I added extra div to the post. Now it looks like this:

<div data-theme-toc="true"> </div>
<div data-theme-profile="manual">
## Chapter 1
## Chapter 2
</div>

But the TOC is not visible in this case. How can it be fixed?

3 Likes

Hi, I noticed an odd interaction with DiscoTOC and Slack integration. Basically the header links don’t properly post.

See details here

2 Likes

That is because the heading links do not include the path to the topic. For example <a name="overview" href="#overview">. The Chat Integration plugin is attempting to convert relative links into absolute links by prepending the forum’s root URL to any links in the post, but that is not going to work for the header links because the path to the topic is missing.

A possible solution would be for us to add the path to the topic to the TOC href element. For example, instead of setting <a name="overview" href="#overview">, the href element would be set to something like /t/your-topic-slug/1234#overview".

2 Likes

Hello,

How I can add into all my existing post the toc ?
I don’t want add this manually :slight_smile:
Perhaps with rake post ?

regards

Ludo

1 Like

Is there any way to make the entire TOC show up at once instead of dynamically hiding most of it? A full post outline can be useful for finding a section without knowing and clicking through its ancestry, or so you can just read all the section names as a way to skim a post.

2 Likes

Hi there! We recently installed DiscoTOC for our forums and were wondering if it’s possible to get the component to read alt text in images? We’ve used images for some patch note headers…

like so:
Performance and Stability

And unfortunately the TOC system doesn’t seem to be able to parse an image as a header, creating a blank entry on the list and creating a link that takes you to a blank page. Is there any workaround for this beyond “don’t use images”? Thank you! Love the system otherwise.

1 Like

My guess is that the solution is to not use images as headings, but possibly there will be a way to get it to work by adding some code to your site that hooks into the DiscoTOC code. Whether or not it’s worth looking into that will depend on how important it is for you to use images in the post’s headings.

3 Likes

We’ve been using images as headers in our patch notes consistently for quite some time now, and it’s a part of our branding and presentation; not just on the forums, but on Steam and such as well. We would like to have the ability to continue using images as headers while using DiscoTOC in order to remain consistent.

DiscoTOC has been great for other things such as for an AMA recap, a megapost about our dedicated server launcher app, new player guides, etc. We like the system a lot, but would love for a little extra functionality for the way we present patch notes.

1 Like

I would second this feature request. I can see that this might result in long TOCs, but at least one could add an “expand all” button or Link?

1 Like

The heading anchor functionality on this component slightly conflicts with the Automatic header links functionality added in 2.7.0beta6, since headings get two icons on hover, one from Discourse and one from DiscoTOC. Is there a way round this?

1 Like

Hello,

You can hide the Automatic header links anchor with

.anchor {
  display: none;
}

Hi dodesz,

I made the post width much larger than the default one, and after install this component it looks something wrong, could you tell me how to fix this problem?

:heart: thanks!

1 Like

On a forum running Discourse 2.8.0.beta4 (90232af778), including the DiscoTOC component leads to an error message:

The component had been activated before and raised an issue with the previously installed Discourse version as well, although I cannot say which version that was.

Are you able to find any error messages related to the issue in your site’s error logs?

That error message is a backend error, while DiscoTOC is a front-end theme-component so it’s hard for those to be related. Do you have any plugins installed?

1 Like

Unfortunately, I couldn’t find anything useful in the /logs.

I do, here’s the relevant excerpt from app.yml:

hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/discourse/discourse-openid-connect.git
          - git clone https://github.com/discourse/discourse-checklist.git
          - git clone https://github.com/discourse/discourse-push-notifications.git
          - git clone https://github.com/discourse/discourse-characters-required.git
          - git clone https://github.com/angusmcleod/discourse-news.git
          - git clone https://github.com/discourse/discourse-data-explorer.git
          - git clone https://github.com/DNOeV/discourse-watch-category.git
          - git clone https://github.com/discourse/discourse-footnote.git
          - git clone https://github.com/discourse/discourse-knowledge-explorer.git

When a header is within a quote, the header doesn’t show up in the TOC. Could this behavior be changed?

This header won’t show up in TOC

Quoted content

This header DOES show up in TOC

Quoted content

I don’t know how it is planned to work but normally no because it’s part of quote, not a heading of that text.

1 Like

Could you try using the html <blockquote> instead? That would allow the header # to be at the start of a line.

Eg:

<blockquote>

### Anchor Header

</blockquote>

Anchor Header

I’ve not tried it in a TOC, but it seems to work with the auto-anchor-headers in a regular post.