Skip to content

Commit 3c13792

Browse files
committed
Format
1 parent 3fd8dac commit 3c13792

File tree

5 files changed

+64
-41
lines changed

5 files changed

+64
-41
lines changed

.vscode/settings.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,5 @@
77
["style \\=([^;]*);", "\"([^\"]*)\""],
88
["style \\=([^;]*);", "\\`([^\\`]*)\\`"]
99
],
10-
"tailwindCSS.classAttributes": [
11-
"class",
12-
"className",
13-
"style",
14-
".*Style"
15-
]
10+
"tailwindCSS.classAttributes": ["class", "className", "style", ".*Style"]
1611
}

src/components/DocumentView/BlockContentRef.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,15 @@ export async function BlockContentRef(props: BlockProps<DocumentBlockContentRef>
3333
);
3434
}
3535

36-
async function SpaceRefCard(props: { resolved: ResolvedContentRef } & BlockProps<DocumentBlockContentRef>) {
36+
async function SpaceRefCard(
37+
props: { resolved: ResolvedContentRef } & BlockProps<DocumentBlockContentRef>,
38+
) {
3739
const { context, style, resolved } = props;
3840
const spaceId = context.contentRefContext?.space.id;
3941

40-
if (!spaceId) { return null; }
42+
if (!spaceId) {
43+
return null;
44+
}
4145

4246
const spaceCustomization = await ignoreAPIError(getSpaceCustomization(spaceId));
4347
const customFavicon = spaceCustomization?.favicon;
@@ -46,7 +50,15 @@ async function SpaceRefCard(props: { resolved: ResolvedContentRef } & BlockProps
4650

4751
return (
4852
<Card
49-
leadingIcon={<LogoIcon icon={customIcon} emoji={customEmoji} alt='' sizes={[{ width: 24 }]} style={['object-contain', 'size-6']} />}
53+
leadingIcon={
54+
<LogoIcon
55+
icon={customIcon}
56+
emoji={customEmoji}
57+
alt=""
58+
sizes={[{ width: 24 }]}
59+
style={['object-contain', 'size-6']}
60+
/>
61+
}
5062
href={resolved.href}
5163
title={resolved.text}
5264
style={style}

src/components/Header/HeaderLogo.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,14 @@ function LogoFallback(props: HeaderLogoProps) {
100100
const customEmoji = 'emoji' in customization.favicon ? customization.favicon.emoji : undefined;
101101
return (
102102
<>
103-
<LogoIcon icon={customIcon} emoji={customEmoji} alt='' sizes={[{ width: 32 }]} style={['object-contain', 'size-8']} fetchPriority='high'/>
103+
<LogoIcon
104+
icon={customIcon}
105+
emoji={customEmoji}
106+
alt=""
107+
sizes={[{ width: 32 }]}
108+
style={['object-contain', 'size-8']}
109+
fetchPriority="high"
110+
/>
104111
<h1
105112
className={tcls(
106113
'text-pretty',

src/components/icons/LogoIcon.tsx

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,49 @@
1-
import { CustomizationThemedURL } from "@gitbook/api";
1+
import { CustomizationThemedURL } from '@gitbook/api';
22

33
import { Image } from '@/components/utils';
4-
import { absoluteHref } from "@/lib/links";
4+
import { absoluteHref } from '@/lib/links';
55

6-
import { Emoji } from "../primitives";
6+
import { Emoji } from '../primitives';
77

8-
9-
export function LogoIcon(props: { icon?: CustomizationThemedURL; emoji?: string } & Omit<React.ComponentProps<typeof Image>, 'sources'>) {
8+
export function LogoIcon(
9+
props: { icon?: CustomizationThemedURL; emoji?: string } & Omit<
10+
React.ComponentProps<typeof Image>,
11+
'sources'
12+
>,
13+
) {
1014
const { icon, emoji, alt, ...imageProps } = props;
1115

1216
if (emoji && !icon) {
1317
return <Emoji code={emoji} style="text-xl" />;
1418
}
1519

16-
return <Image
17-
alt={alt ?? ''}
18-
sources={icon ? {
19-
light: {
20-
src: icon.light,
21-
aspectRatio: '1',
22-
},
23-
dark: {
24-
src: icon.dark,
25-
aspectRatio: '1',
26-
},
27-
} : {
28-
light: {
29-
src: absoluteHref('~gitbook/icon?size=medium&theme=light', true),
30-
size: { width: 256, height: 256 },
31-
},
32-
dark: {
33-
src: absoluteHref('~gitbook/icon?size=medium&theme=dark', true),
34-
size: { width: 256, height: 256 },
35-
},
36-
}}
37-
{...imageProps}
38-
/>;
20+
return (
21+
<Image
22+
alt={alt ?? ''}
23+
sources={
24+
icon
25+
? {
26+
light: {
27+
src: icon.light,
28+
aspectRatio: '1',
29+
},
30+
dark: {
31+
src: icon.dark,
32+
aspectRatio: '1',
33+
},
34+
}
35+
: {
36+
light: {
37+
src: absoluteHref('~gitbook/icon?size=medium&theme=light', true),
38+
size: { width: 256, height: 256 },
39+
},
40+
dark: {
41+
src: absoluteHref('~gitbook/icon?size=medium&theme=dark', true),
42+
size: { width: 256, height: 256 },
43+
},
44+
}
45+
}
46+
{...imageProps}
47+
/>
48+
);
3949
}

src/lib/references.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { getBlockById, getBlockTitle } from './document';
1515
import { gitbookAppHref, pageHref, PageHrefContext } from './links';
1616
import { getPagePath, resolvePageId } from './pages';
1717

18-
1918
export interface ResolvedContentRef {
2019
/** Text to render in the content ref */
2120
text: string;
@@ -165,7 +164,7 @@ export async function resolveContentRef(
165164
contentRef.space === space.id
166165
? space
167166
: await ignoreAPIError(getSpace(contentRef.space));
168-
167+
169168
if (!targetSpace) {
170169
return {
171170
href: gitbookAppHref(`/s/${contentRef.space}`),
@@ -177,7 +176,7 @@ export async function resolveContentRef(
177176
return {
178177
href: targetSpace.urls.published ?? targetSpace.urls.app,
179178
text: targetSpace.title,
180-
active: true
179+
active: true,
181180
};
182181
}
183182

0 commit comments

Comments
 (0)