Skip to content

Commit 09e3bfb

Browse files
committed
Formatting
1 parent 26ab764 commit 09e3bfb

File tree

5 files changed

+41
-21
lines changed

5 files changed

+41
-21
lines changed

packages/gitbook/src/app/(site)/fetch.ts

+13-6
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ export async function fetchContentData() {
4040
const site = siteStructure.site;
4141

4242
const sections = siteStructure.sections;
43-
const section = siteStructure.sections?.find(section => section.id === content.siteSectionId);
44-
45-
const spaces = siteStructure.spaces ?? (section ? parseSpacesFromSiteSpaces(section.siteSpaces) : []);
46-
43+
const section = siteStructure.sections?.find((section) => section.id === content.siteSectionId);
44+
45+
const spaces =
46+
siteStructure.spaces ?? (section ? parseSpacesFromSiteSpaces(section.siteSpaces) : []);
47+
4748
// we grab the space attached to the parent as it contains overriden customizations
4849
const spaceRelativeToParent = spaces?.find((space) => space.id === content.spaceId);
4950

@@ -153,8 +154,14 @@ async function fetchSiteStructure(args: {
153154
getCurrentSiteCustomization({ organizationId, siteId, siteSpaceId: undefined }),
154155
]);
155156

156-
const siteSections = siteStructure.type === 'sections' && siteStructure.structure ? siteStructure.structure : null;
157-
const siteSpaces = siteStructure.type === 'siteSpaces' && siteStructure.structure ? parseSpacesFromSiteSpaces(siteStructure.structure) : null;
157+
const siteSections =
158+
siteStructure.type === 'sections' && siteStructure.structure
159+
? siteStructure.structure
160+
: null;
161+
const siteSpaces =
162+
siteStructure.type === 'siteSpaces' && siteStructure.structure
163+
? parseSpacesFromSiteSpaces(siteStructure.structure)
164+
: null;
158165

159166
// override the title with the customization title
160167
const site = {

packages/gitbook/src/components/SiteSectionTabs/SiteSectionTab.tsx

+20-8
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,21 @@ import { tcls } from '@/lib/tailwind';
77

88
import { Button, Link } from '../primitives';
99

10-
export function SiteSectionTabs(props: { sections: SiteSection[]; section: SiteSection; }) {
10+
export function SiteSectionTabs(props: { sections: SiteSection[]; section: SiteSection }) {
1111
const { sections, section: currentSection } = props;
1212

13-
const tabs = sections.map((section) => ({ id: section.id, label: section.title, path: section.urls.published ?? '' }));
13+
const tabs = sections.map((section) => ({
14+
id: section.id,
15+
label: section.title,
16+
path: section.urls.published ?? '',
17+
}));
1418

1519
const currentTabRef = React.useRef<HTMLAnchorElement>(null);
1620
const navRef = React.useRef<HTMLDivElement>(null);
1721

18-
const [currentIndex, setCurrentIndex] = React.useState(sections.findIndex(section => section.id === currentSection?.id) || 0);
22+
const [currentIndex, setCurrentIndex] = React.useState(
23+
sections.findIndex((section) => section.id === currentSection?.id) || 0,
24+
);
1925
const [tabDimensions, setTabDimensions] = React.useState<{
2026
left: number;
2127
width: number;
@@ -34,7 +40,7 @@ export function SiteSectionTabs(props: { sections: SiteSection[]; section: SiteS
3440
if (currentTabRef.current && navRef.current) {
3541
const rect = currentTabRef.current.getBoundingClientRect();
3642
const navRect = navRef.current.getBoundingClientRect();
37-
setTabDimensions({ left: rect.left - navRect.left, width: rect.width });
43+
setTabDimensions({ left: rect.left - navRect.left, width: rect.width });
3844
}
3945
}
4046
window.addEventListener('resize', onResize);
@@ -43,7 +49,7 @@ export function SiteSectionTabs(props: { sections: SiteSection[]; section: SiteS
4349

4450
const scale = (tabDimensions?.width ?? 0) * 0.01;
4551
const startPos = `${tabDimensions?.left ?? 0}px`;
46-
52+
4753
const hasMoreSections = false; /** TODO: determine whether we need to show the more button */
4854

4955
return tabs.length > 0 ? (
@@ -57,7 +63,7 @@ export function SiteSectionTabs(props: { sections: SiteSection[]; section: SiteS
5763
} as React.CSSProperties
5864
}
5965
>
60-
<div
66+
<div
6167
className={tcls(
6268
'relative flex gap-2',
6369
/* add a pseudo element for active tab indicator */
@@ -78,7 +84,7 @@ export function SiteSectionTabs(props: { sections: SiteSection[]; section: SiteS
7884
/>
7985
))}
8086
</div>
81-
{ hasMoreSections ? <MoreSectionsButton /> : null }
87+
{hasMoreSections ? <MoreSectionsButton /> : null}
8288
</nav>
8389
) : null;
8490
}
@@ -95,7 +101,13 @@ const Tab = React.forwardRef<
95101
!active && 'hover:bg-dark/1 dark:hover:bg-light/2 transition-colors',
96102
)}
97103
>
98-
<Link ref={ref} onClick={onClick} className={tcls('inline-flex w-full truncate')} role="tab" href={href}>
104+
<Link
105+
ref={ref}
106+
onClick={onClick}
107+
className={tcls('inline-flex w-full truncate')}
108+
role="tab"
109+
href={href}
110+
>
99111
{label}
100112
</Link>
101113
</div>

packages/gitbook/src/components/SpaceLayout/SpaceLayout.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,11 @@ export function SpaceLayout(props: {
7474
customization={customization}
7575
/>
7676
<div className={tcls('scroll-nojump')}>
77-
{ sections && section ? <div className={tcls(CONTAINER_STYLE)}>
78-
<SiteSectionTabs sections={sections} section={section} />
79-
</div> : null }
77+
{sections && section ? (
78+
<div className={tcls(CONTAINER_STYLE)}>
79+
<SiteSectionTabs sections={sections} section={section} />
80+
</div>
81+
) : null}
8082
<div
8183
className={tcls(
8284
'flex',

packages/gitbook/src/lib/api.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -745,12 +745,12 @@ export const getSiteStructure = cache({
745745
name: 'api.getSiteStructure',
746746
tag: ({ siteId }) => getAPICacheTag({ tag: 'site', site: siteId }),
747747
get: async (
748-
args: {
748+
args: {
749749
organizationId: string;
750-
siteId: string,
750+
siteId: string;
751751
/** Site share key that can be used as context to resolve site space published urls */
752752
siteShareKey: string | undefined;
753-
},
753+
},
754754
options: CacheFunctionOptions,
755755
) => {
756756
const response = await api().orgs.getSiteStructure(

packages/gitbook/src/middleware.ts

-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ export async function middleware(request: NextRequest) {
211211
}
212212
}
213213

214-
215214
// For tests, we make it possible to enable search indexation
216215
// using a query parameter.
217216
const xGitBookSearchIndexation =

0 commit comments

Comments
 (0)