mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-23 02:53:29 +00:00
24f5e73bbe
* Start * Improve generation * Improve style * Lint * Use tilde instead of dot in the url * Improve style * Fix page group * Format * Add visual tests for PDF
57 lines
1.2 KiB
TypeScript
57 lines
1.2 KiB
TypeScript
import { ContentRef, JSONDocument } from '@gitbook/api';
|
|
|
|
import { ContentPointer } from '@/lib/api';
|
|
import { ResolvedContentRef } from '@/lib/references';
|
|
import { ClassValue } from '@/lib/tailwind';
|
|
|
|
import { Blocks } from './Blocks';
|
|
|
|
export interface DocumentContext {
|
|
/**
|
|
* Content being rendered.
|
|
*/
|
|
content?: ContentPointer;
|
|
|
|
/**
|
|
* Resolve a content reference.
|
|
*/
|
|
resolveContentRef: (ref: ContentRef) => Promise<ResolvedContentRef | null>;
|
|
|
|
/**
|
|
* Transform an ID to be added to the DOM.
|
|
*/
|
|
getId?: (id: string) => string;
|
|
}
|
|
|
|
export interface DocumentContextProps {
|
|
context: DocumentContext;
|
|
}
|
|
|
|
/**
|
|
* Render an entire document.
|
|
*/
|
|
export function DocumentView(
|
|
props: DocumentContextProps & {
|
|
document: JSONDocument;
|
|
|
|
/** Style passed to the container */
|
|
style?: ClassValue;
|
|
|
|
/** Style passed to all blocks */
|
|
blockStyle?: ClassValue;
|
|
},
|
|
) {
|
|
const { document, style, blockStyle = [], context } = props;
|
|
|
|
return (
|
|
<Blocks
|
|
nodes={document.nodes}
|
|
document={document}
|
|
ancestorBlocks={[]}
|
|
blockStyle={blockStyle}
|
|
style={['space-y-6', style]}
|
|
context={context}
|
|
/>
|
|
);
|
|
}
|