mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 01:53:26 +00:00
wip
This commit is contained in:
@@ -83,5 +83,9 @@ export function getOpenAPIContext(args: {
|
||||
id: block.meta?.id,
|
||||
blockKey: block.key,
|
||||
locale,
|
||||
hideSummaryAndDescription:
|
||||
'hideSummaryAndDescription' in block.data
|
||||
? Boolean(block.data.hideSummaryAndDescription)
|
||||
: false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -124,7 +124,8 @@
|
||||
|
||||
.openapi-method-head,
|
||||
.openapi-method-options,
|
||||
.openapi-method-trace {
|
||||
.openapi-method-trace,
|
||||
.openapi-method-hook {
|
||||
@apply bg-tint;
|
||||
}
|
||||
|
||||
@@ -1011,4 +1012,8 @@ body:has(.openapi-select-popover) {
|
||||
|
||||
.openapi-path-copy-button-icon svg {
|
||||
@apply text-tint size-4;
|
||||
}
|
||||
|
||||
.openapi-operation-no-summary .openapi-column-preview {
|
||||
@apply pt-0;
|
||||
}
|
||||
@@ -113,6 +113,7 @@ export async function PageHeader(props: {
|
||||
>
|
||||
<PageIcon page={page} style={['text-tint-subtle ', 'shrink-0']} />
|
||||
{page.title}
|
||||
{'computed' in page && page.computed?.props.deprecated ? <span className="openapi-deprecated">Deprecated</span> : null}
|
||||
</h1>
|
||||
) : null}
|
||||
{page.description && page.layout.description ? (
|
||||
|
||||
@@ -38,15 +38,38 @@ export function PageDocumentItem(props: { page: ClientTOCPageDocument }) {
|
||||
) : null
|
||||
}
|
||||
>
|
||||
{page.emoji || page.icon ? (
|
||||
{page.computed?.props.method ? (
|
||||
<span>
|
||||
<MethodTag method={page.computed.props.method} />
|
||||
{page.title}
|
||||
</span>
|
||||
) : page.emoji || page.icon ? (
|
||||
<span className="flex items-center gap-3">
|
||||
<TOCPageIcon page={page} />
|
||||
{page.title}
|
||||
</span>
|
||||
) : (
|
||||
page.title
|
||||
)}
|
||||
) : page.title}
|
||||
</ToggleableLinkItem>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
const MethodTag = ({ method }: { method: string }) => {
|
||||
|
||||
const formattedMethod = (() => {
|
||||
switch (method) {
|
||||
case 'delete':
|
||||
return 'DEL';
|
||||
case 'options':
|
||||
return 'OPT';
|
||||
default:
|
||||
return method;
|
||||
}
|
||||
})();
|
||||
|
||||
return (
|
||||
<span className={`openapi-method openapi-method-${method} text-xs!`}>
|
||||
{formattedMethod}
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { GitBookSiteContext } from '@/lib/context';
|
||||
import { getPagePaths, hasPageVisibleDescendant } from '@/lib/pages';
|
||||
import { resolveContentRef } from '@/lib/references';
|
||||
import { removeUndefined } from '@/lib/typescript';
|
||||
import type { ContentRef, RevisionPage } from '@gitbook/api';
|
||||
import type { ComputedContentSource, ContentRef, RevisionPage } from '@gitbook/api';
|
||||
import assertNever from 'assert-never';
|
||||
|
||||
export type ClientTOCPageLink = {
|
||||
@@ -24,6 +24,7 @@ export type ClientTOCPageDocument = {
|
||||
icon?: string;
|
||||
pathnames: string[];
|
||||
descendants?: ClientTOCPage[];
|
||||
computed?: ComputedContentSource
|
||||
};
|
||||
|
||||
export type ClientTOCPageGroup = {
|
||||
@@ -79,6 +80,7 @@ export async function encodeClientTableOfContents(
|
||||
pathnames: getPagePaths(rootPages, page),
|
||||
descendants,
|
||||
type: 'document',
|
||||
computed: 'computed' in page && page.computed ? page.computed : undefined,
|
||||
})
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -19,7 +19,13 @@ export function OpenAPIOperation(props: {
|
||||
const context = resolveOpenAPIContext(contextInput);
|
||||
|
||||
return (
|
||||
<div className={clsx('openapi-operation', className)}>
|
||||
<div
|
||||
className={clsx(
|
||||
'openapi-operation',
|
||||
context.hideSummaryAndDescription && 'openapi-operation-no-summary',
|
||||
className
|
||||
)}
|
||||
>
|
||||
<OpenAPISummary data={data} context={context} />
|
||||
<div className="openapi-columns">
|
||||
<OpenAPIColumnSpec data={data} context={context} />
|
||||
|
||||
@@ -24,7 +24,7 @@ export function OpenAPIColumnSpec(props: {
|
||||
])}
|
||||
</div>
|
||||
) : null}
|
||||
<OpenAPIOperationDescription operation={operation} context={context} />
|
||||
{!context.hideSummaryAndDescription ? <OpenAPIOperationDescription operation={operation} context={context} /> : null}
|
||||
<OpenAPISpec data={data} context={clientContext} />
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -24,15 +24,18 @@ export function OpenAPISummary(props: {
|
||||
|
||||
return (
|
||||
<div className="openapi-summary" id={operation.summary ? undefined : context.id}>
|
||||
{(operation.deprecated || operation['x-stability']) && (
|
||||
{(operation.deprecated && !context.hideSummaryAndDescription) ||
|
||||
operation['x-stability'] ? (
|
||||
<div className="openapi-summary-tags">
|
||||
{operation.deprecated && <div className="openapi-deprecated">Deprecated</div>}
|
||||
{operation.deprecated && !context.hideSummaryAndDescription && (
|
||||
<div className="openapi-deprecated">Deprecated</div>
|
||||
)}
|
||||
{operation['x-stability'] && (
|
||||
<OpenAPIStability stability={operation['x-stability']} />
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{title
|
||||
) : null}
|
||||
{title && !context.hideSummaryAndDescription
|
||||
? context.renderHeading({
|
||||
deprecated: operation.deprecated ?? false,
|
||||
stability: operation['x-stability'],
|
||||
|
||||
@@ -63,6 +63,12 @@ export interface OpenAPIContext extends Omit<OpenAPIClientContext, '$$isClientCo
|
||||
* Specification URL.
|
||||
*/
|
||||
specUrl: string;
|
||||
|
||||
/**
|
||||
* Whether to hide the summary and description of the operation.
|
||||
* @default false
|
||||
*/
|
||||
hideSummaryAndDescription?: boolean;
|
||||
}
|
||||
|
||||
export type OpenAPIUniversalContext = OpenAPIClientContext | OpenAPIContext;
|
||||
|
||||
Reference in New Issue
Block a user