mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-10-01 14:38:39 +00:00
85ec1884e6
* Start methods to resolve refs * bun * Start package * Add code to resolve ref * Continue * Deref * Start monorepo * Continue * Fix ref resolver * Style a bit more * Start toggling section * Continue * Start displaying query/path/headers params * Hide respo se if empty * Fix recursive refs * Simplify interactive and styling * Display enums * Format * Improve type name being displayed * Improve naming * Render oneOf/anyOf/allOf * Handle circular references * Start variable in server url * Use client component for the spec part * Improve CSS sizing * Display open api blocks in aside * Make aside an overlay * Improve stickiness of openapi * Align document on the left when api page * Improve general layout * Better align * Fix padding in aside * Use syntax highlighting * Show sample of response * Improve code generation * Improve code generated * Format * Format * Rename to OpenAPI * Skip deprecated properties and handle additionalProperties * Use discriminator for naming * Better name enum * Make entire header toggeable * Format and lint * Add curl example * Improve curl * style pass * Start securities * Bun * Fix TS * Improve label * Start markdown * Improve code samples * Test * Use custom skeleton for api block * Format * Add support for redocly code samples * Fix api blocks in aside * Use typography for markdown * Format * Fix spacing in markdown * Render headers * Format * Format --------- Co-authored-by: Sebastian Graz <graz@live.se>
54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
import { DocumentBlockCode, JSONDocument } from '@gitbook/api';
|
|
|
|
import { CodeBlock } from './CodeBlock';
|
|
|
|
/**
|
|
* Plain code block with syntax highlighting.
|
|
* For simplicity, this is just a wrapper around the CodeBlock component, emulating a document.
|
|
*/
|
|
export function PlainCodeBlock(props: { code: string; syntax: string }) {
|
|
const { code, syntax } = props;
|
|
|
|
const block: DocumentBlockCode = {
|
|
object: 'block',
|
|
type: 'code',
|
|
data: {
|
|
syntax,
|
|
},
|
|
nodes: code.split('\n').map((line) => ({
|
|
object: 'block',
|
|
type: 'code-line',
|
|
data: {},
|
|
nodes: [
|
|
{
|
|
object: 'text',
|
|
leaves: [
|
|
{
|
|
object: 'leaf',
|
|
text: line,
|
|
marks: [],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
})),
|
|
};
|
|
|
|
const document: JSONDocument = {
|
|
object: 'document',
|
|
data: {},
|
|
nodes: [block],
|
|
};
|
|
|
|
return (
|
|
<CodeBlock
|
|
document={document}
|
|
context={{
|
|
resolveContentRef: async () => null,
|
|
}}
|
|
block={block}
|
|
ancestorBlocks={[]}
|
|
/>
|
|
);
|
|
}
|