Add link to generate links in PDF mode

This commit is contained in:
Samy Pessé
2023-11-03 16:59:37 -04:00
parent 85af5fd4e2
commit 2d4faaf396
11 changed files with 177 additions and 97 deletions
+4 -3
View File
@@ -4,14 +4,15 @@ import { BlockProps } from './Block';
import { Inlines } from './Inlines';
import { DocumentBlockHeading } from '@gitbook/api';
import { getBlockTextStyle } from './spacing';
import { pageLocalId } from '@/lib/links';
export function Heading(props: BlockProps<DocumentBlockHeading>) {
const { block, style, ...contextProps } = props;
const { block, style, context, ...rest } = props;
const textStyle = getBlockTextStyle(block);
const Tag = TAGS[block.type];
const id = block.meta?.id ?? '';
const id = pageLocalId(context.page, block.meta?.id ?? '', context);
return (
<Tag id={id} className={tcls(textStyle.textSize, 'group', 'relative', style)}>
@@ -56,7 +57,7 @@ export function Heading(props: BlockProps<DocumentBlockHeading>) {
</a>
</div>
<Inlines {...contextProps} nodes={block.nodes} />
<Inlines {...rest} context={context} nodes={block.nodes} />
</Tag>
);
}
+2 -2
View File
@@ -6,7 +6,7 @@ import { Inlines } from './Inlines';
import { DocumentBlockImage, DocumentBlockImages } from '@gitbook/api';
export function Images(props: BlockProps<DocumentBlockImages>) {
const { block, style, ...contextProps } = props;
const { block, style, context } = props;
return (
<div
@@ -28,7 +28,7 @@ export function Images(props: BlockProps<DocumentBlockImages>) {
block={node}
style={[i > 0 && 'mt-4', style]}
siblings={block.nodes.length}
{...contextProps}
context={context}
/>
))}
</div>
@@ -9,19 +9,19 @@ export async function RecordCard(
record: TableRecordKV;
},
) {
const { block, view, record } = props;
const { block, view, record, context } = props;
const coverFile = view.coverDefinition
? (record[1].values[view.coverDefinition]?.[0] as string)
: null;
const cover = coverFile
? await resolveContentRef({ kind: 'file', file: coverFile }, props.context)
? await resolveContentRef({ kind: 'file', file: coverFile }, context)
: null;
const targetRef = view.targetDefinition
? (record[1].values[view.targetDefinition] as ContentRef)
: null;
const target = targetRef ? await resolveContentRef(targetRef, props.context) : null;
const target = targetRef ? await resolveContentRef(targetRef, context) : null;
const body = (
<>