diff --git a/src/components/schema-display.tsx b/src/components/schema-display.tsx index b32408d..de4039d 100644 --- a/src/components/schema-display.tsx +++ b/src/components/schema-display.tsx @@ -8,49 +8,95 @@ import { } from "@/components/ui/accordion"; import { CopyButton } from "./copy-button"; import { PrettySchemaDisplay } from "./pretty-schema-display"; +import { Badge } from "@/components/ui/badge"; interface SchemaDisplayProps { schemas: any[]; } export function SchemaDisplay({ schemas }: SchemaDisplayProps) { + const groupedSchemas = schemas.reduce((acc, schema) => { + const type = Array.isArray(schema["@type"]) + ? schema["@type"].join(", ") + : schema["@type"] || "Untyped"; + if (!acc[type]) { + acc[type] = []; + } + acc[type].push(schema); + return acc; + }, {} as Record); + + const SchemaContent = ({ schema }: { schema: any }) => { + const schemaJson = JSON.stringify(schema, null, 2); + return ( + <> +
+
+ + Copy Raw JSON + + +
+
+ + + ); + }; + return (

- Found {schemas.length} schema block{schemas.length > 1 ? "s" : ""} on - this page. + Found {schemas.length} schema block{schemas.length > 1 ? "s" : ""} in{" "} + {Object.keys(groupedSchemas).length} type + {Object.keys(groupedSchemas).length > 1 ? "s" : ""}.

Expand to see details.

- - {schemas.map((schema, index) => { - const schemaType = schema["@type"] || `Schema Block ${index + 1}`; - const schemaJson = JSON.stringify(schema, null, 2); - - return ( + + {Object.entries(groupedSchemas).map( + ([type, schemaGroup], groupIndex) => ( - {schemaType} - - -
-
- - Copy Raw JSON - - -
+
+ {type} + {schemaGroup.length}
- + + + {schemaGroup.length > 1 ? ( +
+ + {schemaGroup.map((schema, schemaIndex) => ( + + + {type} #{schemaIndex + 1} + + + + + + ))} + +
+ ) : ( + + )}
- ); - })} + ) + )}
);