ElMassimo / ElMassimo/iles

Provide tree of headings in `@island/headings`

Open
#226 3 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
1.2k
Forks
36
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**
Since the `@islands/headings` packages provides headings as a list, instead of a tree, I am unable to render a proper tree in the table of contents.

**Describe the solution you'd like**
I would prefer that during parsing of the AST, headings be compiled into a tree-structure instead of (or in addition to) a list so that the relationships between headings is also available in the `post.meta` field.

**Describe alternatives you've considered**
This could be accomplished by a separate plugin but a lot of the code would be duplicated between the `@islands/heading` module and the separate one.

**Additional context**
Having the headings as a tree would make it possible to index the headings and provide meaningful numbering to them as well. For example, something like this would be possible if the headings were a tree.

```
§1 Chapter
§1.1 Section
§1.2 Section
§1.2.1 Subsection
§2 Chapter
...
```

I'm happy to make a PR if this change seems useful to the general user base.

Contributor guide

No contributing guide indexed for this repository

Research direction

Locate the @islands/headings AST parser and inspect how headings are exposed through post.meta. Clarify the tree shape and whether the existing list should remain available, then cover nested headings such as chapters, sections, and subsections; done means consumers can access their heading relationships for table-of-contents indexing and numbering.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
content
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.