-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from ethdebug/schema-listing
Allow users to view full schema listings
- Loading branch information
Showing
11 changed files
with
436 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ const config: Config = { | |
rules: [ | ||
{ | ||
test: /\.yaml$/, | ||
use: "yaml-loader" | ||
use: "raw-loader" | ||
} | ||
] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import YAML from "yaml"; | ||
import { | ||
type DescribeSchemaOptions, | ||
describeSchema | ||
} from "@site/src/schemas"; | ||
import CodeBlock from "@theme/CodeBlock"; | ||
import Tabs from "@theme/Tabs"; | ||
import TabItem from "@theme/TabItem"; | ||
|
||
export interface SchemaListingProps extends DescribeSchemaOptions { | ||
} | ||
|
||
export default function SchemaListing(props: SchemaListingProps): JSX.Element { | ||
const { | ||
id: qualifiedId, | ||
pointer, | ||
schema, | ||
yaml | ||
} = describeSchema(props); | ||
|
||
const id = | ||
qualifiedId | ||
? qualifiedId.startsWith("schema:") | ||
? qualifiedId.slice(7) | ||
: qualifiedId | ||
: undefined; | ||
|
||
const reference = id && pointer | ||
? `${id}${pointer}` | ||
: id | ||
? id | ||
: undefined; | ||
|
||
return ( | ||
<Tabs groupId="schema-language"> | ||
<TabItem value="yaml" label="YAML"> | ||
<CodeBlock | ||
className="schema-listing" | ||
language="yaml" | ||
showLineNumbers | ||
title={ | ||
reference | ||
? reference | ||
: "schema.yaml" | ||
} | ||
>{ | ||
yaml | ||
}</CodeBlock> | ||
</TabItem> | ||
<TabItem value="json" label="JSON"> | ||
<CodeBlock | ||
className="schema-listing" | ||
language="json" | ||
showLineNumbers | ||
title={ | ||
reference | ||
? `${reference}` | ||
: "schema.json" | ||
} | ||
>{ | ||
JSON.stringify(schema, undefined, 2) | ||
}</CodeBlock> | ||
</TabItem> | ||
</Tabs> | ||
); | ||
} |
Oops, something went wrong.