Open
Conversation
Fixes ghostty-org#436 # Problem: If you check https://ghostty.org/docs/features/applescript, https://ghostty.org/docs/install/release-notes/1-3-0 or https://ghostty.org/docs/install/release-notes/1-0-1, two of the pages will have a broken link to "Security" in the navigation on the right. Which page is not broken is random and is decided during build-time, based on which page is built first. This because the heading id generator "remembers" ids to make sure they don't clash. If multiple headings have the same id, a counter is appended (e.g. security-2). However, there's a discrepancy: The heading id generator for the navigation only considers the headings on the current page when generating the navigation. However, the actual heading IDs are counted "globally" across all pages. As a result, two of the three example pages will have "security-2" and "security-3" as IDs, even though there is no other security heading on the page. # Solution The quick fix is to make sure that the "encounteredIDs" map is scoped to the page (the "node" in remark-heading-ids.mjs" is effectively a page). Every page will have its own map. Something to consider for the long-term would be to reduce the duplication of heading id generation. There are two separate implementations (one to generate the headings and one to generate the navigation), leading to this problem in the first place. # Proof that this didn't break anything To check whether the de-duplication still works, visit https://ghostty.org/docs/install/build (or rather, your local or staging equivalent). This page has two headings "Dependencies", both which still have their correct IDs assigned after this change.
|
@peterjeschke is attempting to deploy a commit to the Ghostty Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #436
Problem:
If you check https://ghostty.org/docs/features/applescript, https://ghostty.org/docs/install/release-notes/1-3-0 or https://ghostty.org/docs/install/release-notes/1-0-1, two of the pages will have a broken link to "Security" in the navigation on the right. Which page is not broken is random and is decided during build-time, based on which page is built first.
This because the heading id generator "remembers" ids to make sure they don't clash. If multiple headings have the same id, a counter is appended (e.g. security-2). However, there's a discrepancy: The heading id generator for the navigation only considers the headings on the current page when generating the navigation. However, the actual heading IDs are counted "globally" across all pages. As a result, two of the three example pages will have "security-2" and "security-3" as IDs, even though there is no other security heading on the page.
Solution
The quick fix is to make sure that the "encounteredIDs" map is scoped to the page (the "node" in remark-heading-ids.mjs" is effectively a page). Every page will have its own map.
Something to consider for the long-term would be to reduce the duplication of heading id generation. There are two separate implementations (one to generate the headings and one to generate the navigation), leading to this problem in the first place.
Proof that this didn't break anything
To check whether the de-duplication still works, visit https://ghostty.org/docs/install/build (or rather, your local or staging equivalent). This page has two headings "Dependencies", both which still have their correct IDs assigned after this change.