ToC is useful when creating a table.
Please add support to it.
This is something thatâs more likely to be available as a card in the upcoming Koenig editor.
Has this been added? Because I donât seem to see how to do it still.
No. There would be an announcement and this topic would be closed if/when the feature was added.
Itâs not in the current backlog but a long-term goal is allowing custom editor cards to be created and installed which would allow third parties to create this type of functionality.
A âtable of contentâ card would be nice.
(I guess this would run into the same issues as the âfootnotes cardâ: Weâll need a way for a card to interact with other cards)
First they would have to develop some form of anchor for a header, where an anchor gets a link on every post, then from there it would be very easy to impement.
The problem with the current way of using anchors is that we need some easy way of doing offset. All blogs that use the ghost theme has that navigation bar at the top of every page:
So if you make a header in a markdown-card like this:
<h2 id="hello">This is a header</h2>
And you setup a link by typing some text
and right click on that text and insert the link to #hello
(your id from your header in the markdown-card, you get this effect (notice how the top bar covers the title):
Now, this is how it is supposed to work, but with the Ghost theme, it just doesnât fit in.
As for doing a ToC, it is pretty easy using LaTex, but I wouldnât bother before they implement some easy way to offset links (which they probably wonât)
Edit:
Right now it is possible for âcardsâ (well, the outcome of them) to interact using links, but it really is just the offset issue, as I see it. Just put the link in a markdown-card like this:
<a href="#hello">Link</a>
Edit2:
This was the closest thing I could find, but we still have the offset issue. Maybe there is an easy fix, but the way I see it is just to set the .scrollTop = link_location-60px in some css, if that is at all possible. Then you would get the desired result.
Table of contents
This is the introduction
Some introduction text, formatted in heading 2 style
Some paragraph
The first paragraph text
Sub paragraph
This is a sub paragraph, formatted in heading 3 style
Another paragraph
The second paragraph text
Copy-paste this into markdown card :)
# Table of contents
1. [Introduction](#introduction)
2. [Some paragraph](#paragraph1)
1. [Sub paragraph](#subparagraph1)
3. [Another paragraph](#paragraph2)
## This is the introduction <a name="introduction"></a>
Some introduction text, formatted in heading 2 style
## Some paragraph <a name="paragraph1"></a>
The first paragraph text
### Sub paragraph <a name="subparagraph1"></a>
This is a sub paragraph, formatted in heading 3 style
## Another paragraph <a name="paragraph2"></a>
The second paragraph text
All headers added via rich-text or though markdown already have an id="my-title"
attribute added automatically (based on the header content) which can be used in ToC links like <a href="#my-title">My Title</a>
.
There are numerous ways to generate a ToC with a client-side script, Automatic Table of Contents | CSS-Tricks - CSS-Tricks is a good tutorial covering the basics.
Alternatively if youâre using Ghost headless you can generate ToCâs in your static files, thereâs an example component gatsby/react component in the source of our docs site
I wouldnât bother before they implement some easy way to offset links (which they probably wonât)
This is completely up to the theme developer, there are multiple JS approaches that can be taken depending on the particular use-case and desired behaviour.
I agree, there are many JS approahces, but many people on here are just looking for a quick solution that they can do right in their editor. Personally, I havenât personally gotten around to try and implement such a feature, but definitely excited for the new Ghost update!
Iâm hoping that the theme developers adds it, but I would not assume they would, as there is probably bigger features that needs their time.
If you really would want a quickfix (quick-bad-SEO-fix), this would be it. Not recommended. But I say try it in a markdown-card and get a feel for what a solution could look like
<h2 id="hiddenheader">This is a header</h2>
<style> #hiddenheader:target {display: block;position: relative; visibility: hidden; }</style>
<h2>The actual header</h2>
<a href="#hiddenheader">Link</a>
Hey there! Found a solution
Has there been any updates on this? I realize that this is a few years old now.