Skip to content

Conversation

@YDX-2147483647
Copy link
Contributor

@YDX-2147483647 YDX-2147483647 commented Jul 27, 2025

Changes

Resolves #194
Resolves #230

  • feat: Support multi-level table of contents
  • fix: Correct IDs of functions in group (e.g., calc.abs) — by changing #definitions- to #functions-
  • fix: Correct parameter IDs — by refactoring into buildParamId
Official Before After

Official: #definitions-at-index

Before: #definitions-at-at-parameters-index

After: #definitions-at-index

Analysis

Things are quite tricky.

First of all, the typst-docs crate generates hrefs in table of contents and cross links, while website is responsible for assigning ids in the main content. This PR displays hrefs in all levels in table of contens, and correct ids.

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.

Page (kind) Function Parameter ID
figure (function) figure body #parameters-body
figure (function) figure.caption body #definitions-caption-body
calc (group) calc.abs value #functions-abs-value
array (type) array.at index #definitions-at-index
array (type) Constructor value #constructor-value
Outdated description

These are the only two occurences.

$ rg '[-]?parameters-' website/src/
website/src/components/ui/FunctionParameters.tsx
26:                                             id={`parameters-${param.name}`}

website/src/components/ui/FunctionDefinition.tsx
31:                                                                             href={`#parameters-${param.name}`}

And they exists since the very beginning (#117).

@YDX-2147483647 YDX-2147483647 marked this pull request as draft July 27, 2025 15:12
@YDX-2147483647 YDX-2147483647 marked this pull request as ready for review July 27, 2025 15:31
@3w36zj6 3w36zj6 self-requested a review July 27, 2025 16:45
@3w36zj6
Copy link
Member

3w36zj6 commented Jul 27, 2025

Hi @YDX-2147483647,
Looks good to me, thanks!

Once other maintainers approve, it will be merged.

This comment was marked as outdated.

@YDX-2147483647
Copy link
Contributor Author

YDX-2147483647 commented Jul 28, 2025

@YDX-2147483647 YDX-2147483647 marked this pull request as draft July 28, 2025 01:37
@YDX-2147483647 YDX-2147483647 changed the title fix: Remove prefix and name from the id of function parameters fix: Correct anchor IDs of functions and their parameters Jul 29, 2025
@YDX-2147483647 YDX-2147483647 marked this pull request as ready for review July 29, 2025 08:14
@YDX-2147483647
Copy link
Contributor Author

YDX-2147483647 commented Jul 29, 2025

It's ready for review now... I found that there are five id patterns. Please refer to the (updated) PR description.

Update: Still buggy. /docs/reference/model/figure/#figure-placement should be #parameters-placement.
Update 2: Just a small typo. Fixed.

@YDX-2147483647 YDX-2147483647 marked this pull request as ready for review July 29, 2025 09:18
@YDX-2147483647 YDX-2147483647 force-pushed the patch-1 branch 2 times, most recently from 00ba866 to 529f643 Compare July 29, 2025 10:05
@3w36zj6 3w36zj6 self-requested a review July 29, 2025 10:09
@3w36zj6 3w36zj6 requested a review from Copilot July 29, 2025 10:10
Copy link
Contributor

Copilot AI left a 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 buildParamId function 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]>
Copy link
Member

@kimushun1101 kimushun1101 left a 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)

Copy link
Contributor

@gomazarashi gomazarashi left a 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!

Copy link
Member

@3w36zj6 3w36zj6 left a 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!

@YDX-2147483647
Copy link
Contributor Author

YDX-2147483647 commented Aug 1, 2025 via email

@3w36zj6 3w36zj6 merged commit c43a3fa into typst-jp:main Aug 1, 2025
5 checks passed
@YDX-2147483647 YDX-2147483647 deleted the patch-1 branch August 1, 2025 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The hash anchor to a parameter in page might be wrong 目次にサブセクションの見出しのリンクが存在しない

5 participants