@@ -2,6 +2,7 @@ import type { FC } from "hono/jsx";
22import { basePath } from "../../metadata" ;
33import { Translation } from "../../translation/" ;
44import type { Func } from "../../types/model" ;
5+ import { normalizeDetailBlocks } from "../../utils/normalizeModel" ;
56import { joinPath } from "../../utils/path" ;
67import { ChevronRightIcon } from "../icons" ;
78import { HtmlContent } from "./HtmlContent" ;
@@ -58,22 +59,35 @@ export const FunctionParameters: FC<FunctionParametersProps> = ({
5859 </ div >
5960 </ h4 >
6061
61- < div class = "mb-3 text-gray-700" >
62- < HtmlContent html = { param . details } />
63- </ div >
64-
65- { param . default && (
66- < p class = "mt-3 text-sm" >
67- < span class = "font-medium" >
68- < Translation translationKey = "defaultValue" />
69- </ span > { " " }
70- < span class = "text-gray-700" >
71- < HtmlContent html = { param . default } />
72- </ span >
73- </ p >
74- ) }
75-
76- { /* Put all collapsible blocks after non-collapsible blocks. */ }
62+ { normalizeDetailBlocks ( param ) . map ( ( block ) => {
63+ switch ( block . kind ) {
64+ case "html" :
65+ return (
66+ < div class = "mb-3 text-gray-700" >
67+ < HtmlContent html = { block . content } />
68+ </ div >
69+ ) ;
70+ case "example" :
71+ return (
72+ < details class = "my-4 folding-example group" >
73+ < summary class = "flex items-center gap-1 text-sm font-medium text-blue-600 cursor-pointer hover:text-blue-800" >
74+ < div class = "w-4 h-4 text-gray-400 transform transition-transform duration-200 group-open:rotate-90" >
75+ < ChevronRightIcon />
76+ </ div >
77+ < Translation
78+ translationKey = "showExample"
79+ title = { block . content . title }
80+ />
81+ </ summary >
82+ < div class = "mt-2 bg-white p-3 rounded-md border border-gray-200 text-sm" >
83+ < HtmlContent html = { block . content . body } />
84+ </ div >
85+ </ details >
86+ ) ;
87+ default :
88+ return null ;
89+ }
90+ } ) }
7791
7892 { param . strings . length > 0 && (
7993 < details
@@ -104,18 +118,15 @@ export const FunctionParameters: FC<FunctionParametersProps> = ({
104118 </ details >
105119 ) }
106120
107- { param . example && (
108- < details class = "my-4 folding-example group" >
109- < summary class = "flex items-center gap-1 text-sm font-medium text-blue-600 cursor-pointer hover:text-blue-800" >
110- < div class = "w-4 h-4 text-gray-400 transform transition-transform duration-200 group-open:rotate-90" >
111- < ChevronRightIcon />
112- </ div >
113- < Translation translationKey = "showExample" />
114- </ summary >
115- < div class = "mt-2 bg-white p-3 rounded-md border border-gray-200 text-sm" >
116- < HtmlContent html = { param . example } />
117- </ div >
118- </ details >
121+ { param . default && (
122+ < p class = "mt-3 text-sm" >
123+ < span class = "font-medium" >
124+ < Translation translationKey = "defaultValue" />
125+ </ span > { " " }
126+ < span class = "text-gray-700" >
127+ < HtmlContent html = { param . default } />
128+ </ span >
129+ </ p >
119130 ) }
120131 </ div >
121132 ) ) }
0 commit comments