Table of content: How would you do it?

Hello, I’m stuck trying to figure out how to make a table of contents like in this exemple (https://flexapp.club/how-to-invest-nft/) with bubble.

Is there a way to auto-detect every H2 in my blog article and put them in a repeating group with a DoSearchFor?

This is my database for my Articles :

H1 are stored in Article_heading and all the rest including the H2 are stored in Article_desc, if I have to store H2 separately it’s likely to become a mess since all articles don’t have the same number of H2

Hope you understood my problem :grinning_face_with_smiling_eyes:

Thank you

Get rid of your description datatype. Create a “section” datatype, indexed so that things are in the right order. Each Section has the attributes (“fields”) “H2” and “contents”, and “index”(for ordering).

To wrap up you would have something like this:

Article

Date
Heading
iD
Image
Sections | List of sections

Sections
Header
Contents
Index (number)

Maybe an article has no sections just a title and content. In that case you would just save one sections leaving it’s header blank since it already has it’s heading under the article datatype. No need to index the section there either but still good practice to put 1 (maybe said article will be edited in the future and more sections added)

1 Like

Wow didn’t know I could take a datatype in another datatype, that opens up so much possibilities! Thank you so much, you solved my problem :slight_smile: