diff --git a/packages/gitbook/src/lib/references.test.ts b/packages/gitbook/src/lib/references.test.ts index db8c0e6d8..209c888a1 100644 --- a/packages/gitbook/src/lib/references.test.ts +++ b/packages/gitbook/src/lib/references.test.ts @@ -627,12 +627,12 @@ describe('resolveContentRef for direct space links', () => { { label: 'API guides' }, { label: 'Authentification' }, { label: 'Référence', href: targetSiteSpace.urls.published }, - { label: 'Getting started', icon: null, href: expect.any(String) }, + { label: 'Getting started', icon: null }, ]); expect(result?.ancestors?.[0]?.href).toBeUndefined(); expect(result?.ancestors?.[1]?.href).toBeUndefined(); expect(result?.ancestors?.[2]?.href).toBeUndefined(); - expect(result?.ancestors?.[4]?.href).toBeTruthy(); + expect(result?.ancestors?.[4]?.href).toBeUndefined(); }); it('uses the first document as the target for a page-group reference', async () => { diff --git a/packages/gitbook/src/lib/references.tsx b/packages/gitbook/src/lib/references.tsx index e174a2bc3..3a099cd98 100644 --- a/packages/gitbook/src/lib/references.tsx +++ b/packages/gitbook/src/lib/references.tsx @@ -276,7 +276,11 @@ export async function resolveContentRef( style={iconStyle} /> ) : null, - href: linker.toPathForPage({ page: ancestor, pages: revision.pages }), + // A group's own URL only redirects to its first page. + href: + ancestor.type === 'group' + ? undefined + : linker.toPathForPage({ page: ancestor, pages: revision.pages }), })) ?? []; if (!page) { return null;