sveltejs / sveltejs/kit

Expose list of (heading) IDs found on each page at build time

Open
#9,848 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the problem

I'd like to have a nav palette with fuzzy search for all headings with ids anywhere in the app. Here's my current setup listing only pages but not their sections.

Screenshot 2023-05-04 at 16 32 34

Thanks to handleMissingId = 'fail', the build fails when I link to a non-existent id on an existing page:

<a href="existing-page#but-missing-id">will raise at build time</a>

So at least at build time, a list of all IDs on a page must already exist in kit's internals.

Describe the proposed solution

Would be great if that data could be made available for building a better "jump to section" experience on docs pages.

Alternatives considered

No response

Importance

nice to have

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the build-time handling of handleMissingId and the existing page and ID data in kit's internals. Determine how a per-page list of heading IDs could be exposed for navigation, then verify that consumers can access the data and that missing-ID validation still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
build-system, web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.