From 357af3f6d21cabc52d985f2d6fe0244a44aa142d Mon Sep 17 00:00:00 2001 From: Peter White <1788320+peterwhite@users.noreply.github.com> Date: Mon, 21 Sep 2026 11:45:24 +0200 Subject: [PATCH] Fix RSS discovery for pages without updates (#4626) --- .changeset/fix-rss-discovery.md | 5 +++++ .../src/components/PageBody/PageBody.tsx | 9 +++++++++ .../src/components/SitePage/SitePage.tsx | 4 ---- packages/gitbook/tests/rss.test.ts | 19 +++++++++++++++++++ 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 .changeset/fix-rss-discovery.md diff --git a/.changeset/fix-rss-discovery.md b/.changeset/fix-rss-discovery.md new file mode 100644 index 000000000..23751a09c --- /dev/null +++ b/.changeset/fix-rss-discovery.md @@ -0,0 +1,5 @@ +--- +"gitbook": patch +--- + +Only advertise RSS feeds on pages with Updates blocks. diff --git a/packages/gitbook/src/components/PageBody/PageBody.tsx b/packages/gitbook/src/components/PageBody/PageBody.tsx index 1dd4d1a31..481afc937 100644 --- a/packages/gitbook/src/components/PageBody/PageBody.tsx +++ b/packages/gitbook/src/components/PageBody/PageBody.tsx @@ -25,6 +25,7 @@ import { import { getLLMsTxtURL, getPageMarkdownURL } from '@/lib/llms-directive'; import type { AncestorRevisionPage } from '@/lib/pages'; import { tcls } from '@/lib/tailwind'; +import { getPageRSSURL } from '@/routes/rss'; const LINK_PREVIEW_MAX_COUNT = 500; @@ -86,6 +87,14 @@ export async function PageBody(props: { return ( + {contentHasUpdates ? ( + + ) : null}
// Team at Vercel is aware of this and will ensure it will be omitted when the value is empty in future versions of Next.js // https://gitbook.slack.com/archives/C04K6MV5W1K/p1763034072958419?thread_ts=1762937203.511629&cid=C04K6MV5W1K diff --git a/packages/gitbook/tests/rss.test.ts b/packages/gitbook/tests/rss.test.ts index 7b0ad5845..016b4411a 100644 --- a/packages/gitbook/tests/rss.test.ts +++ b/packages/gitbook/tests/rss.test.ts @@ -29,3 +29,22 @@ it('should not expose a RSS feed for a page without updates (root page)', async expect(response.status).toBe(404); expect(await response.text()).toBe('No updates found in page'); }); + +for (const path of ['', '/text-page', '/blocks/updates']) { + it(`only advertises an RSS feed when the page has updates (${path || '/'})`, async () => { + const response = await fetch( + getContentTestURL(`https://gitbook.gitbook.io/test-gitbook-open${path}`), + { headers: { 'User-Agent': 'Googlebot' } } + ); + expect(response.status).toBe(200); + const html = await response.text(); + const links = Array.from(html.matchAll(/]*>/g), ([link]) => link).filter((link) => + link.includes('type="application/rss+xml"') + ); + expect(links).toHaveLength(path === '/blocks/updates' ? 1 : 0); + if (path === '/blocks/updates') { + expect(links[0]).toContain('/blocks/updates/rss.xml'); + expect(html.slice(0, html.indexOf(''))).toContain('type="application/rss+xml"'); + } + }); +}