Repository navigation
🏗️🔧:give headings the anchors links point to - #1916
Merged
Merged
Conversation
markdown-it-anchor keeps a heading's punctuation and percent-encodes it, so "logLevel?" became #loglevel%3F and "fetchContent()" became #fetchcontent(). TypeDoc links to those as #loglevel and #fetchcontent, which is GitHub's rule as well, so once the SDK reference is imported three of its links reach the top of the page instead of the heading, and every optional property or method heading has an anchor nothing can guess. The handbook had three such headings too. Headings now take GitHub's anchor: lowercased, with punctuation other than hyphens and underscores dropped and spaces turned into hyphens. A build of the site with the 3.0.0 reference imported has no link left pointing at a missing anchor. Signed-off-by: Derek Lewis <DerekNonGeneric@inf.is> Assisted-by: Claude-Code:claude-opus-5
✅ Deploy Preview for gh-pages-openinf ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Requested by DerekNonGeneric
Before: markdown-it-anchor kept a heading's punctuation and percent-encoded it, so "logLevel?" got the id
loglevel%3Fand "fetchContent()" gotfetchcontent(). TypeDoc links to those as#logleveland#fetchcontent. With the SDK 3.0.0 reference imported, three of its links (two onGhFileImporterOptions, one onisContentFile) went to the top of the page instead of the heading, and no optional property or method heading had an anchor anyone could guess. Three handbook headings had the same problem, for example#show-the-command%2C-not-the-ceremony.After: headings get GitHub's anchors: lowercased, with punctuation other than
-and_dropped and spaces turned into hyphens. A build of the site with the 3.0.0 reference imported has no internal link pointing at a missing page or anchor, and no id holds a percent-encoded character.Nothing linked to the old encoded ids. A check over the built site found no link that used them.
How: a small
headingSluginbuild/shared/heading-slug.mts(exported as@openinf/portal/build/heading-slug, with unit tests), passed to markdown-it-anchor asslugify. To verify it, I ran the SDK'sversion-packagesanddocs:artifactin a scratch checkout, imported the result withunpack-sdk-api-artifact.mtsandcompile.importSdkApiDocs, built the site, and checked everyhrefand fragment. That import was only for the check and isn't part of this change.Summary by CodeRabbit