@@ -8,7 +8,7 @@ type FunctionItem = Awaited<ReturnType<typeof getCollection>>[number];
88// Define a structure for function parameters
99type FunctionParameter = {
1010 name : string ;
11- type : string ; // Adjust type as needed (e.g., string | string[])
11+ type : string ;
1212 description ?: string ;
1313 optional ?: boolean ;
1414} ;
@@ -19,6 +19,7 @@ type FunctionDetails = {
1919 pair ?: boolean ;
2020 examples ?: { code : string ; description ?: string } [ ] ;
2121 notes ?: string [ ] ;
22+ important_notes ?: string [ ] ;
2223 parameters ?: FunctionParameter [ ] ;
2324} ;
2425
@@ -36,7 +37,6 @@ export type FunctionData = {
3637 server ?: any ;
3738} ;
3839
39- // Use the specific FunctionDetails type
4040export type TypedFunctionData = {
4141 shared ?: FunctionDetails ;
4242 client ?: FunctionDetails ;
@@ -47,42 +47,42 @@ export const functionTypePrettyName = {
4747 'client' : 'Client-side' ,
4848 'server' : 'Server-side' ,
4949 'shared' : 'Shared' ,
50- } as const ; // Use 'as const' for stricter typing of keys
50+ } as const ;
5151
5252function getFunctionType ( data : FunctionData ) : FunctionType {
5353 if ( data . shared ) return 'shared' ;
5454 if ( data . client ) return 'client' ;
5555 return 'server' ;
5656}
5757function getFunctionTypePretty ( data : FunctionData ) : string {
58- // No need for fallback, getFunctionType guarantees a valid FunctionType
5958 const funcType = getFunctionType ( data ) ;
6059 return functionTypePrettyName [ funcType ] ;
6160}
6261
63- // Define a return type for getFunctionInfo
6462export type FunctionInfo = {
6563 description : string ;
6664 type : FunctionType ;
6765 typePretty : string ;
6866 pair : boolean ;
6967 examples : { code : string ; description ?: string } [ ] ;
70- notes ?: string [ ] ; // Added notes
71- parameters ?: FunctionParameter [ ] ; // Added parameters
68+ notes ?: string [ ] ;
69+ important_notes ?: string [ ] ;
70+ parameters ?: FunctionParameter [ ] ;
7271} ;
7372
7473export function getFunctionInfo ( data : TypedFunctionData ) : FunctionInfo {
7574 const type = getFunctionType ( data ) ;
76- const details = data [ type ] ?? { } ; // Get details based on type, default to empty object
75+ const details = data [ type ] ?? { } ;
7776
7877 return {
7978 description : details . description || '' ,
8079 type : type ,
8180 typePretty : getFunctionTypePretty ( data ) ,
8281 pair : details . pair || false ,
8382 examples : details . examples || [ ] ,
84- notes : details . notes , // Extract notes (will be undefined if not present)
85- parameters : details . parameters || [ ] , // Extract parameters
83+ notes : details . notes || [ ] ,
84+ important_notes : details . important_notes || [ ] ,
85+ parameters : details . parameters || [ ] ,
8686 } ;
8787}
8888
@@ -95,16 +95,14 @@ let functionsByTypeByCategory: FunctionsByTypeByCategory = {
9595} ;
9696
9797for ( let func of functionsCollection ) {
98- // Assuming func.filePath exists, handle potential undefined if necessary
99- const normalizedPath = path . normalize ( func . id ) ; // Use func.id which includes the path relative to content dir
98+ const normalizedPath = path . normalize ( func . id ) ;
10099 const folder = path . basename ( path . dirname ( normalizedPath ) ) ;
101100 if ( ! functionsByCategory [ folder ] ) {
102101 functionsByCategory [ folder ] = [ ] ;
103102 }
104103 functionsByCategory [ folder ] . push ( func ) ;
105104
106105 const funcType = getFunctionType ( func . data ) ;
107- // Ensure the folder exists for the specific type
108106 if ( ! functionsByTypeByCategory [ funcType ] ?. [ folder ] ) {
109107 functionsByTypeByCategory [ funcType ] [ folder ] = [ ] ;
110108 }
0 commit comments