Skip to content

Commit d9ee1a7

Browse files
authored
Merge branch 'main' into brett/RND-2311-openapi-enum
2 parents 846de0e + a7af3ca commit d9ee1a7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+692
-316
lines changed

Diff for: .changeset/grumpy-humans-yawn.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'gitbook': minor
3+
---
4+
5+
Support resolution of new site URLs with sections

Diff for: .changeset/light-candles-trade.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'gitbook': patch
3+
---
4+
5+
Improve perception of fast loading by not rendering skeletons for individual blocks in the top part of the viewport

Diff for: .changeset/lovely-lies-complain.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'gitbook': minor
3+
---
4+
5+
Add support for searching results in a sections site

Diff for: .changeset/purple-pugs-attend.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'gitbook': patch
3+
---
4+
5+
Fix flickering when displaying an "Ask" answer with code blocks

Diff for: .changeset/slimy-rules-think.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'gitbook': minor
3+
---
4+
5+
Added support for new Reusable Content block.

Diff for: .changeset/wet-houses-grab.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'gitbook': patch
3+
---
4+
5+
Improving the look and feel of new section tabs

Diff for: bun.lockb

-392 Bytes
Binary file not shown.

Diff for: packages/gitbook/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"clean": "rm -rf ./.next && rm -rf ./public/~gitbook/static"
1717
},
1818
"dependencies": {
19-
"@gitbook/api": "^0.69.0",
19+
"@gitbook/api": "^0.72.0",
2020
"@gitbook/cache-do": "workspace:*",
2121
"@gitbook/emoji-codepoints": "workspace:*",
2222
"@gitbook/icons": "workspace:*",

Diff for: packages/gitbook/src/app/(site)/(content)/[[...pathname]]/page.tsx

+19-14
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export default async function Page(props: {
3232
const {
3333
content: contentPointer,
3434
contentTarget,
35+
sections,
3536
space,
3637
site,
3738
customization,
@@ -75,12 +76,29 @@ export default async function Page(props: {
7576
page,
7677
};
7778

79+
const withSections = Boolean(sections && sections.length > 0);
80+
const headerOffset = { sectionsHeader: withSections, topHeader: withTopHeader };
81+
7882
return (
7983
<>
8084
{withFullPageCover && page.cover ? (
8185
<PageCover as="full" page={page} cover={page.cover} context={contentRefContext} />
8286
) : null}
83-
<div className={tcls('flex', 'flex-row')}>
87+
{/* We use a flex row reverse to render the aside first because the page is streamed. */}
88+
<div className="flex flex-row-reverse justify-end">
89+
{page.layout.outline ? (
90+
<PageAside
91+
space={space}
92+
site={site}
93+
customization={customization}
94+
page={page}
95+
document={document}
96+
withHeaderOffset={headerOffset}
97+
withFullPageCover={withFullPageCover}
98+
withPageFeedback={withPageFeedback}
99+
context={contentRefContext}
100+
/>
101+
) : null}
84102
<PageBody
85103
space={space}
86104
pointer={contentPointer}
@@ -94,19 +112,6 @@ export default async function Page(props: {
94112
withPageFeedback && !page.layout.outline
95113
}
96114
/>
97-
{page.layout.outline ? (
98-
<PageAside
99-
space={space}
100-
site={site}
101-
customization={customization}
102-
page={page}
103-
document={document}
104-
withHeaderOffset={withTopHeader}
105-
withFullPageCover={withFullPageCover}
106-
withPageFeedback={withPageFeedback}
107-
context={contentRefContext}
108-
/>
109-
) : null}
110115
</div>
111116
<React.Suspense fallback={null}>
112117
<PageClientLayout />

Diff for: packages/gitbook/src/components/Ads/Ad.tsx

+14-15
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,22 @@ export function Ad({
8282
(siteAdsStatus === SiteAdsStatus.Pending ||
8383
siteAdsStatus === SiteAdsStatus.InReview));
8484

85-
if (!realZoneId) {
85+
if (!realZoneId && !showPlaceholderAd) {
8686
return;
8787
}
8888

8989
(async () => {
90-
const result = await renderAd({
91-
placement,
92-
ignore: ignore || preview,
93-
zoneId: realZoneId,
94-
mode,
95-
source: showPlaceholderAd ? 'placeholder' : 'live',
96-
});
90+
const result = showPlaceholderAd
91+
? await renderAd({ source: 'placeholder' })
92+
: realZoneId
93+
? await renderAd({
94+
placement,
95+
ignore: ignore || preview,
96+
zoneId: realZoneId,
97+
mode,
98+
source: 'live',
99+
})
100+
: undefined;
97101

98102
if (cancelled) {
99103
return;
@@ -109,13 +113,8 @@ export function Ad({
109113
};
110114
}, [visible, zoneId, ignore, placement, mode, siteAdsStatus]);
111115

112-
const viaUrl = new URL('https://www.gitbook.com');
113-
viaUrl.searchParams.set('utm_source', 'content');
114-
viaUrl.searchParams.set('utm_medium', 'ads');
115-
viaUrl.searchParams.set('utm_campaign', spaceId);
116-
117116
return (
118-
<div ref={containerRef} className={tcls(style)}>
117+
<div ref={containerRef} className={tcls(style)} data-visual-test="removed">
119118
{ad ? (
120119
<>
121120
{ad}
@@ -132,7 +131,7 @@ function AdSponsoredLink(props: { spaceId: string }) {
132131

133132
const viaUrl = new URL('https://www.gitbook.com');
134133
viaUrl.searchParams.set('utm_source', 'content');
135-
viaUrl.searchParams.set('utm_medium', 'sponsoring');
134+
viaUrl.searchParams.set('utm_medium', 'sponsored-by-gitbook');
136135
viaUrl.searchParams.set('utm_campaign', spaceId);
137136

138137
return (

Diff for: packages/gitbook/src/components/Ads/AdClassicRendering.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { AdItem } from './types';
88
/**
99
* Classic rendering for an ad.
1010
*/
11-
export async function AdClassicRendering({ ad }: { ad: AdItem }) {
11+
export function AdClassicRendering({ ad }: { ad: AdItem }) {
1212
return (
1313
<a
1414
className={tcls(
@@ -33,7 +33,7 @@ export async function AdClassicRendering({ ad }: { ad: AdItem }) {
3333
<img
3434
alt="Ads logo"
3535
className={tcls('rounded-md')}
36-
src={await getResizedImageURL(ad.smallImage, { width: 192, dpr: 2 })}
36+
src={getResizedImageURL(ad.smallImage, { width: 192, dpr: 2 })}
3737
/>
3838
</div>
3939
) : (
@@ -43,7 +43,7 @@ export async function AdClassicRendering({ ad }: { ad: AdItem }) {
4343
>
4444
<img
4545
alt="Ads logo"
46-
src={await getResizedImageURL(ad.logo, { width: 192 - 48, dpr: 2 })}
46+
src={getResizedImageURL(ad.logo, { width: 192 - 48, dpr: 2 })}
4747
/>
4848
</div>
4949
)}

Diff for: packages/gitbook/src/components/Ads/AdCoverRendering.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { AdCover } from './types';
99
/**
1010
* Cover rendering for an ad.
1111
*/
12-
export async function AdCoverRendering({ ad }: { ad: AdCover }) {
13-
const largeImage = await getResizedImageURL(ad.largeImage, { width: 128, dpr: 2 });
12+
export function AdCoverRendering({ ad }: { ad: AdCover }) {
13+
const largeImage = getResizedImageURL(ad.largeImage, { width: 128, dpr: 2 });
1414

1515
return (
1616
<a

Diff for: packages/gitbook/src/components/Ads/renderAd.tsx

+18-10
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ import { AdPixels } from './AdPixels';
88
import adRainbow from './assets/ad-rainbow.svg';
99
import { AdItem, AdsResponse } from './types';
1010

11-
interface FetchAdOptions {
11+
type FetchAdOptions = FetchLiveAdOptions | FetchPlaceholderAdOptions;
12+
13+
interface FetchLiveAdOptions {
14+
/**
15+
* Source of the ad (live: from the platform)
16+
*/
17+
source: 'live';
1218
/** ID of the zone to fetch Ads for */
1319
zoneId: string;
1420
/** Mode to render the Ad */
@@ -17,12 +23,13 @@ interface FetchAdOptions {
1723
placement: string;
1824
/** If true, we'll not track it as an impression */
1925
ignore: boolean;
26+
}
27+
28+
interface FetchPlaceholderAdOptions {
2029
/**
21-
* Source of the ad (live: from the platform, placeholder: static placeholder)
22-
*
23-
* Defaults to live.
24-
* */
25-
source?: 'live' | 'placeholder';
30+
* Source of the ad (placeholder: static placeholder ad)
31+
*/
32+
source: 'placeholder';
2633
}
2734

2835
/**
@@ -31,9 +38,9 @@ interface FetchAdOptions {
3138
* and properly access user-agent and IP.
3239
*/
3340
export async function renderAd(options: FetchAdOptions) {
34-
const { mode, source = 'live' } = options;
41+
const mode = options.source === 'live' ? options.mode : 'classic';
3542

36-
const result = source === 'live' ? await fetchAd(options) : getPlaceholderAd();
43+
const result = options.source === 'live' ? await fetchAd(options) : getPlaceholderAd();
3744
if (!result || !result.ad.description || !result.ad.statlink) {
3845
return null;
3946
}
@@ -56,7 +63,7 @@ async function fetchAd({
5663
zoneId,
5764
placement,
5865
ignore,
59-
}: FetchAdOptions): Promise<{ ad: AdItem; ip: string } | null> {
66+
}: FetchLiveAdOptions): Promise<{ ad: AdItem; ip: string } | null> {
6067
const { ip, userAgent } = getUserAgentAndIp();
6168

6269
const url = new URL(`https://srv.buysellads.com/ads/${zoneId}.json`);
@@ -101,7 +108,8 @@ function getPlaceholderAd(): { ad: AdItem; ip: string } {
101108
rendering: 'carbon',
102109
smallImage: adRainbow.src,
103110
statimp: '',
104-
statlink: 'https://www.gitbook.com/solutions/open-source',
111+
statlink:
112+
'https://www.gitbook.com/solutions/open-source?utm_campaign=sponsored-content&utm_medium=ad&utm_source=content',
105113
timestamp: Date.now().toString(),
106114
width: '0',
107115
zoneid: '',

Diff for: packages/gitbook/src/components/Cookies/CookiesToast.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export function CookiesToast(props: { privacyPolicy?: string }) {
2727

2828
const onUpdateState = (enabled: boolean) => {
2929
setCookiesTracking(enabled);
30-
3130
// Reload the page to take the change in consideration
3231
window.location.reload();
3332
};
@@ -75,6 +74,7 @@ export function CookiesToast(props: { privacyPolicy?: string }) {
7574
)}
7675
</p>
7776
<button
77+
type="button"
7878
onClick={() => setShow(false)}
7979
aria-label={tString(language, 'cookies_close')}
8080
className={tcls(

0 commit comments

Comments
 (0)