-
Notifications
You must be signed in to change notification settings - Fork 13
fix: Correct anchor IDs of functions and their parameters #232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Hi @YDX-2147483647, Once other maintainers approve, it will be merged. |
|
Oh, I find https://typst.app/docs vs. https://typst-jp.github.io/docs:
Please wait until I or anyone fix other potential problems on anchors… Update: Maybe typst-docs should generate the JSON with IDs. |
|
It's ready for review now... I found that there are five id patterns. Please refer to the (updated) PR description.
|
00ba866 to
529f643
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes anchor ID generation for function parameters and adds support for multi-level table of contents. The main purpose is to align the documentation website's anchor IDs with the official Typst documentation format.
- Introduces a standardized
buildParamIdfunction to generate consistent parameter anchor IDs across different page types - Replaces hardcoded ID prefixes with a unified system that handles top-level functions and nested methods differently
- Adds multi-level table of contents support with proper indentation for nested items
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
website/src/components/ui/type2href.ts |
Adds buildParamId utility function for consistent parameter ID generation |
website/src/components/ui/common/TableOfContents.tsx |
Implements recursive table of contents rendering for multi-level navigation |
website/src/components/ui/FunctionParameters.tsx |
Updates parameter ID generation to use new buildParamId function |
website/src/components/ui/FunctionDisplay.tsx |
Updates prop types and default values for prefix parameter |
website/src/components/ui/FunctionDefinition.tsx |
Updates href generation to use new buildParamId function |
website/src/components/templates/GroupTemplate.tsx |
Changes prefix from "definitions-" to "functions-" for group page methods |
website/src/components/templates/FuncTemplate.tsx |
Removes prefix for top-level function parameters to match official format |
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for your kind contribution.
Confirmation with Netlify was also helpful. Just to be sure, I have confirmed that it works in my local environment, and it was fine.
This PR also fixes #194 (in Japanese)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this! I've confirmed it works on my end. LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, thank you!
|
Let’s merge this!
#234 is another (independent) bug on website generation, and fixing it will use the function `buildParamId` defined in this PR. Therefore, we can’t do any substantive work on that before this PR is merged.
|
Changes
Resolves #194
Resolves #230
calc.abs) — by changing#definitions-to#functions-buildParamIdOfficial:

#definitions-at-indexBefore:

#definitions-at-at-parameters-indexAfter:

#definitions-at-indexAnalysis
Things are quite tricky.
First of all, the
typst-docscrate generateshrefs in table of contents and cross links, whilewebsiteis responsible for assigningids in the main content. This PR displayshrefs in all levels in table of contens, and correctids.Now let's figure out the ID pattern.
There are 7 kinds of page. Among them, only pages of kind function, group, and type contain function parameters.
https://github.com/typst-jp/typst-jp.github.io/blob/fb3a73693e35fa3a78955ce53d7207654f2f56c6/docs/src/model.rs#L48-L61
And their patterns are as the following.
figure(function)figurebody#parameters-bodyfigure(function)figure.captionbody#definitions-caption-bodycalc(group)calc.absvalue#functions-abs-valuearray(type)array.atindex#definitions-at-indexarray(type)value#constructor-valueOutdated description
These are the only two occurences.
And they exists since the very beginning (#117).