diff --git a/website/src/components/templates/FuncTemplate.tsx b/website/src/components/templates/FuncTemplate.tsx index 7c8f032d1b..95e9f4568f 100644 --- a/website/src/components/templates/FuncTemplate.tsx +++ b/website/src/components/templates/FuncTemplate.tsx @@ -1,5 +1,5 @@ import type { FC } from "hono/jsx"; -import type { FuncBody, Page } from "../../types/model"; +import type { Func, FuncBody, Page } from "../../types/model"; import { FunctionDefinition, FunctionDisplay, @@ -70,57 +70,88 @@ export const FuncTemplate: FC = ({ - {content.scope.length > 0 && ( -
-

- 定義 - -

- - {content.scope.map((method, index) => ( -
-

+ + ); +}; + +/** + * If the definitions in `scope` are associated with the top scope on this page, then `parent` should be `undefined`. + * Otherwise, `parent` should describe the parent of these definitions. + */ +function ScopedDefinitions({ + scope, + parent, +}: { scope: Func[]; parent?: { name: string; id: string } | undefined }) { + if (scope.length === 0) { + return null; + } + + /** `parent?.id` as a string */ + const parentId = parent ? `${parent.id}-` : ""; + + // To be consistent with the official typst.app/docs, + // the following heading levels will _not_ increase with the scope level. + return ( +
+

+ {parent ? ( + // Currently, the scope has at most two levels. + // Therefore, it is sufficient to only annotate the direct `parent`. + <> + {parent.name}の定義 + + ) : ( + "定義" + )} + +

+ + {scope.map((method, index) => { + const methodId = `${parentId}definitions-${method.name}`; + + return ( +
+

+ - - {method.name} - - - - {method.element && } - {method.contextual && } - -

- - {method.deprecation && ( -
- -
- )} - -
- + {method.name} + + + + {method.element && } + {method.contextual && } + +

+ + {method.deprecation && ( +
+
+ )} + +
+
- ))} -
- )} - + + +
+ ); + })} + ); -}; +} export default FuncTemplate;