From 8dc137e99438556b73104f705ee5965710464ca5 Mon Sep 17 00:00:00 2001 From: Brett Jephson Date: Fri, 25 Sep 2026 11:27:55 +0100 Subject: [PATCH] Say where a dead link goes in the "Page not found" card A link to a page that no longer exists opens its space on the site, but the card only said the page was gone. It now adds which space the link opens, and the fallback's text is that site space's title instead of "space", which also fixes the title shown on a dead content-ref block card. A dead link into a space outside the site keeps the existing wording and app fallback. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01Rt9YwdSUu7gHehYbEkvEJ8 --- .changeset/giant-years-search.md | 2 +- .../components/DocumentView/BlockContentRef.tsx | 2 +- .../src/components/DocumentView/InlineButton.tsx | 16 ++++++++++------ .../DocumentView/InlineLink/InlineLink.tsx | 2 +- .../DocumentView/NotFoundRefHoverCard.tsx | 13 ++++++++++++- packages/gitbook/src/intl/translations/ar.ts | 1 + packages/gitbook/src/intl/translations/bg.ts | 1 + packages/gitbook/src/intl/translations/cs.ts | 1 + packages/gitbook/src/intl/translations/da.ts | 1 + packages/gitbook/src/intl/translations/de.ts | 1 + packages/gitbook/src/intl/translations/el.ts | 1 + packages/gitbook/src/intl/translations/en.ts | 1 + packages/gitbook/src/intl/translations/es.ts | 1 + packages/gitbook/src/intl/translations/et.ts | 1 + packages/gitbook/src/intl/translations/fi.ts | 1 + packages/gitbook/src/intl/translations/fr.ts | 1 + packages/gitbook/src/intl/translations/he.ts | 1 + packages/gitbook/src/intl/translations/hi.ts | 1 + packages/gitbook/src/intl/translations/hr.ts | 1 + packages/gitbook/src/intl/translations/hu.ts | 1 + packages/gitbook/src/intl/translations/id.ts | 1 + packages/gitbook/src/intl/translations/it.ts | 1 + packages/gitbook/src/intl/translations/ja.ts | 1 + packages/gitbook/src/intl/translations/ko.ts | 1 + packages/gitbook/src/intl/translations/lt.ts | 1 + packages/gitbook/src/intl/translations/lv.ts | 1 + packages/gitbook/src/intl/translations/ms.ts | 1 + packages/gitbook/src/intl/translations/nl.ts | 1 + packages/gitbook/src/intl/translations/no.ts | 1 + packages/gitbook/src/intl/translations/pl.ts | 1 + packages/gitbook/src/intl/translations/pt-br.ts | 1 + packages/gitbook/src/intl/translations/pt.ts | 1 + packages/gitbook/src/intl/translations/ro.ts | 1 + packages/gitbook/src/intl/translations/ru.ts | 1 + packages/gitbook/src/intl/translations/sk.ts | 1 + packages/gitbook/src/intl/translations/sl.ts | 1 + packages/gitbook/src/intl/translations/sv.ts | 1 + packages/gitbook/src/intl/translations/th.ts | 1 + packages/gitbook/src/intl/translations/tr.ts | 1 + packages/gitbook/src/intl/translations/uk.ts | 1 + packages/gitbook/src/intl/translations/vi.ts | 1 + packages/gitbook/src/intl/translations/yue.ts | 1 + packages/gitbook/src/intl/translations/zh-tw.ts | 1 + packages/gitbook/src/intl/translations/zh.ts | 1 + packages/gitbook/src/lib/references.test.ts | 11 +++++++++++ packages/gitbook/src/lib/references.tsx | 3 ++- 46 files changed, 77 insertions(+), 11 deletions(-) diff --git a/.changeset/giant-years-search.md b/.changeset/giant-years-search.md index a062032b0..232cbe413 100644 --- a/.changeset/giant-years-search.md +++ b/.changeset/giant-years-search.md @@ -2,4 +2,4 @@ "gitbook": patch --- -Keep links to GitBook app URLs of spaces in the same site on the site, instead of sending readers to app.gitbook.com. +Keep links to GitBook app URLs of spaces in the same site on the site, instead of sending readers to app.gitbook.com. A link to a page that no longer exists now opens its space on the site, and its "Page not found" card says which space it opens. diff --git a/packages/gitbook/src/components/DocumentView/BlockContentRef.tsx b/packages/gitbook/src/components/DocumentView/BlockContentRef.tsx index be1cb6fe7..23e1c347a 100644 --- a/packages/gitbook/src/components/DocumentView/BlockContentRef.tsx +++ b/packages/gitbook/src/components/DocumentView/BlockContentRef.tsx @@ -29,7 +29,7 @@ export async function BlockContentRef(props: BlockProps return null; } return ( - + = { ...buttonProps, insights: { @@ -107,7 +107,11 @@ export async function InlineLinkButton( ); if (inline.data.ref && !resolved) { - return {button}; + return ( + + {button} + + ); } return button; diff --git a/packages/gitbook/src/components/DocumentView/InlineLink/InlineLink.tsx b/packages/gitbook/src/components/DocumentView/InlineLink/InlineLink.tsx index d1f47e9de..3bf341128 100644 --- a/packages/gitbook/src/components/DocumentView/InlineLink/InlineLink.tsx +++ b/packages/gitbook/src/components/DocumentView/InlineLink/InlineLink.tsx @@ -39,7 +39,7 @@ export async function InlineLink(props: InlineProps) { if (!resolved) { const fallback = resolveContentRefFallback(inline.data.ref, contentContext); return ( - + {fallback ? ( {children} @@ -26,7 +32,12 @@ export async function NotFoundRefHoverCard(
{tString(language, 'notfound_title')}
-

{tString(language, 'notfound_link')}

+

+ {tString(language, 'notfound_link')} + {destination + ? ` ${tString(language, 'notfound_link_opens', destination)}` + : null} +

); diff --git a/packages/gitbook/src/intl/translations/ar.ts b/packages/gitbook/src/intl/translations/ar.ts index 6105037ff..f2f152922 100644 --- a/packages/gitbook/src/intl/translations/ar.ts +++ b/packages/gitbook/src/intl/translations/ar.ts @@ -76,6 +76,7 @@ export const ar: TranslationLanguage = { edit: 'تحرير', notfound_title: 'الصفحة غير موجودة', notfound_link: 'يشير هذا الرابط إلى صفحة تمت إزالتها أو لم تعد موجودة.', + notfound_link_opens: 'بدلاً من ذلك، يفتح هذا الرابط: ${1}.', notfound: 'الصفحة التي تبحث عنها غير موجودة.', notfound_adaptive_title: 'الصفحة غير متاحة', notfound_adaptive: 'قد تكون هذه الصفحة موجودة، لكن قد تحتاج إلى تسجيل الدخول للوصول إليها.', diff --git a/packages/gitbook/src/intl/translations/bg.ts b/packages/gitbook/src/intl/translations/bg.ts index 960ff0327..15fe82b7d 100644 --- a/packages/gitbook/src/intl/translations/bg.ts +++ b/packages/gitbook/src/intl/translations/bg.ts @@ -77,6 +77,7 @@ export const bg: TranslationLanguage = { edit: 'Редактиране', notfound_title: 'Страницата не е намерена', notfound_link: 'Тази връзка сочи към страница, която е премахната или вече не съществува.', + notfound_link_opens: 'Вместо това ще се отвори: ${1}.', notfound: 'Страницата, която търсите, не съществува.', notfound_adaptive_title: 'Страницата не е налична', notfound_adaptive: diff --git a/packages/gitbook/src/intl/translations/cs.ts b/packages/gitbook/src/intl/translations/cs.ts index 96d95e293..2a692f084 100644 --- a/packages/gitbook/src/intl/translations/cs.ts +++ b/packages/gitbook/src/intl/translations/cs.ts @@ -76,6 +76,7 @@ export const cs: TranslationLanguage = { edit: 'Upravit', notfound_title: 'Stránka nenalezena', notfound_link: 'Tento odkaz vede na stránku, která byla odstraněna nebo již neexistuje.', + notfound_link_opens: 'Místo toho se otevře: ${1}.', notfound: 'Stránka, kterou hledáte, neexistuje.', notfound_adaptive_title: 'Stránka není dostupná', notfound_adaptive: diff --git a/packages/gitbook/src/intl/translations/da.ts b/packages/gitbook/src/intl/translations/da.ts index 6a1e8594e..b195b9625 100644 --- a/packages/gitbook/src/intl/translations/da.ts +++ b/packages/gitbook/src/intl/translations/da.ts @@ -76,6 +76,7 @@ export const da: TranslationLanguage = { edit: 'Rediger', notfound_title: 'Siden blev ikke fundet', notfound_link: 'Dette link peger på en side, der er blevet fjernet eller ikke længere findes.', + notfound_link_opens: 'Den åbner ${1} i stedet.', notfound: 'Siden, du leder efter, findes ikke.', notfound_adaptive_title: 'Siden er ikke tilgængelig', notfound_adaptive: diff --git a/packages/gitbook/src/intl/translations/de.ts b/packages/gitbook/src/intl/translations/de.ts index 3ad52e9a6..2a3654950 100644 --- a/packages/gitbook/src/intl/translations/de.ts +++ b/packages/gitbook/src/intl/translations/de.ts @@ -79,6 +79,7 @@ export const de: TranslationLanguage = { notfound_title: 'Seite nicht gefunden', notfound_link: 'Dieser Link verweist auf eine Seite, die entfernt wurde oder nicht mehr existiert.', + notfound_link_opens: 'Stattdessen wird ${1} geöffnet.', notfound: 'Die gesuchte Seite existiert nicht.', notfound_adaptive_title: 'Seite nicht verfügbar', notfound_adaptive: diff --git a/packages/gitbook/src/intl/translations/el.ts b/packages/gitbook/src/intl/translations/el.ts index 6dfa44898..21d549aa4 100644 --- a/packages/gitbook/src/intl/translations/el.ts +++ b/packages/gitbook/src/intl/translations/el.ts @@ -77,6 +77,7 @@ export const el: TranslationLanguage = { edit: 'Επεξεργασία', notfound_title: 'Η σελίδα δεν βρέθηκε', notfound_link: 'Αυτός ο σύνδεσμος οδηγεί σε μια σελίδα που έχει αφαιρεθεί ή δεν υπάρχει πλέον.', + notfound_link_opens: 'Αντί γι’ αυτό ανοίγει: ${1}.', notfound: 'Η σελίδα που αναζητάτε δεν υπάρχει.', notfound_adaptive_title: 'Η σελίδα δεν είναι διαθέσιμη', notfound_adaptive: diff --git a/packages/gitbook/src/intl/translations/en.ts b/packages/gitbook/src/intl/translations/en.ts index df71a95f9..2a38345ea 100644 --- a/packages/gitbook/src/intl/translations/en.ts +++ b/packages/gitbook/src/intl/translations/en.ts @@ -74,6 +74,7 @@ export const en = { edit: 'Edit', notfound_title: 'Page not found', notfound_link: 'This link points to a page that has been removed or no longer exists.', + notfound_link_opens: 'It opens ${1} instead.', notfound: "The page you're looking for doesn't exist.", notfound_adaptive_title: 'Page unavailable', notfound_adaptive: 'This page may exist, but you may need to log in to access it.', diff --git a/packages/gitbook/src/intl/translations/es.ts b/packages/gitbook/src/intl/translations/es.ts index d5653bb4d..39c428124 100644 --- a/packages/gitbook/src/intl/translations/es.ts +++ b/packages/gitbook/src/intl/translations/es.ts @@ -78,6 +78,7 @@ export const es: TranslationLanguage = { edit: 'Editar', notfound_title: 'Página no encontrada', notfound_link: 'Este enlace apunta a una página que ha sido eliminada o ya no existe.', + notfound_link_opens: 'En su lugar, se abre ${1}.', notfound: 'La página que buscas no existe.', notfound_adaptive_title: 'Página no disponible', notfound_adaptive: diff --git a/packages/gitbook/src/intl/translations/et.ts b/packages/gitbook/src/intl/translations/et.ts index bcc9292d7..5deb26f59 100644 --- a/packages/gitbook/src/intl/translations/et.ts +++ b/packages/gitbook/src/intl/translations/et.ts @@ -76,6 +76,7 @@ export const et: TranslationLanguage = { edit: 'Muuda', notfound_title: 'Lehte ei leitud', notfound_link: 'See link viitab lehele, mis on eemaldatud või mida enam ei eksisteeri.', + notfound_link_opens: 'Selle asemel avaneb: ${1}.', notfound: 'Lehte, mida otsite, ei eksisteeri.', notfound_adaptive_title: 'Leht pole saadaval', notfound_adaptive: 'See leht võib olemas olla, kuid juurdepääsuks võib olla vaja sisse logida.', diff --git a/packages/gitbook/src/intl/translations/fi.ts b/packages/gitbook/src/intl/translations/fi.ts index 2531eb240..913735fa8 100644 --- a/packages/gitbook/src/intl/translations/fi.ts +++ b/packages/gitbook/src/intl/translations/fi.ts @@ -77,6 +77,7 @@ export const fi: TranslationLanguage = { edit: 'Muokkaa', notfound_title: 'Sivua ei löytynyt', notfound_link: 'Tämä linkki osoittaa sivulle, joka on poistettu tai jota ei enää ole.', + notfound_link_opens: 'Sen sijaan avautuu: ${1}.', notfound: 'Etsimääsi sivua ei ole olemassa.', notfound_adaptive_title: 'Sivu ei ole saatavilla', notfound_adaptive: diff --git a/packages/gitbook/src/intl/translations/fr.ts b/packages/gitbook/src/intl/translations/fr.ts index acc576a5b..9ed02c442 100644 --- a/packages/gitbook/src/intl/translations/fr.ts +++ b/packages/gitbook/src/intl/translations/fr.ts @@ -77,6 +77,7 @@ export const fr: TranslationLanguage = { edit: 'Modifier', notfound_title: 'Page introuvable', notfound_link: "Ce lien pointe vers une page qui a été supprimée ou n'existe plus.", + notfound_link_opens: 'Le lien ouvre ${1} à la place.', notfound: 'La page que vous cherchez n’existe pas.', notfound_adaptive_title: 'Page inaccessible', notfound_adaptive: diff --git a/packages/gitbook/src/intl/translations/he.ts b/packages/gitbook/src/intl/translations/he.ts index 219282c8a..98dd9f768 100644 --- a/packages/gitbook/src/intl/translations/he.ts +++ b/packages/gitbook/src/intl/translations/he.ts @@ -76,6 +76,7 @@ export const he: TranslationLanguage = { edit: 'עריכה', notfound_title: 'הדף לא נמצא', notfound_link: 'קישור זה מפנה לדף שהוסר או אינו קיים עוד.', + notfound_link_opens: 'במקום זאת ייפתח: ${1}.', notfound: 'הדף שחיפשת אינו קיים.', notfound_adaptive_title: 'הדף אינו זמין', notfound_adaptive: 'ייתכן שהדף קיים, אך ייתכן שעליך להתחבר כדי לגשת אליו.', diff --git a/packages/gitbook/src/intl/translations/hi.ts b/packages/gitbook/src/intl/translations/hi.ts index 24ebda70c..9938504c1 100644 --- a/packages/gitbook/src/intl/translations/hi.ts +++ b/packages/gitbook/src/intl/translations/hi.ts @@ -76,6 +76,7 @@ export const hi: TranslationLanguage = { edit: 'संपादित करें', notfound_title: 'पृष्ठ नहीं मिला', notfound_link: 'यह लिंक ऐसे पृष्ठ पर जाता है जिसे हटा दिया गया है या जो अब मौजूद नहीं है।', + notfound_link_opens: 'इसके बजाय ${1} खुलेगा।', notfound: 'आप जिस पृष्ठ को खोज रहे हैं वह मौजूद नहीं है।', notfound_adaptive_title: 'पृष्ठ उपलब्ध नहीं', notfound_adaptive: 'यह पृष्ठ मौजूद हो सकता है, लेकिन इसे देखने के लिए आपको लॉग इन करना पड़ सकता है।', diff --git a/packages/gitbook/src/intl/translations/hr.ts b/packages/gitbook/src/intl/translations/hr.ts index 2a8328792..5cb3721e3 100644 --- a/packages/gitbook/src/intl/translations/hr.ts +++ b/packages/gitbook/src/intl/translations/hr.ts @@ -76,6 +76,7 @@ export const hr: TranslationLanguage = { edit: 'Uredi', notfound_title: 'Stranica nije pronađena', notfound_link: 'Ova poveznica vodi na stranicu koja je uklonjena ili više ne postoji.', + notfound_link_opens: 'Umjesto toga otvara se: ${1}.', notfound: 'Stranica koju tražite ne postoji.', notfound_adaptive_title: 'Stranica nije dostupna', notfound_adaptive: diff --git a/packages/gitbook/src/intl/translations/hu.ts b/packages/gitbook/src/intl/translations/hu.ts index 0e57021e1..ed4a1a6c9 100644 --- a/packages/gitbook/src/intl/translations/hu.ts +++ b/packages/gitbook/src/intl/translations/hu.ts @@ -77,6 +77,7 @@ export const hu: TranslationLanguage = { edit: 'Szerkesztés', notfound_title: 'Az oldal nem található', notfound_link: 'Ez a hivatkozás egy eltávolított vagy már nem létező oldalra mutat.', + notfound_link_opens: 'Ehelyett ez nyílik meg: ${1}.', notfound: 'A keresett oldal nem létezik.', notfound_adaptive_title: 'Az oldal nem érhető el', notfound_adaptive: 'Ez az oldal létezhet, de a hozzáféréshez lehet, hogy be kell jelentkeznie.', diff --git a/packages/gitbook/src/intl/translations/id.ts b/packages/gitbook/src/intl/translations/id.ts index e9ae77387..7e48e1b73 100644 --- a/packages/gitbook/src/intl/translations/id.ts +++ b/packages/gitbook/src/intl/translations/id.ts @@ -76,6 +76,7 @@ export const id: TranslationLanguage = { edit: 'Edit', notfound_title: 'Halaman tidak ditemukan', notfound_link: 'Tautan ini mengarah ke halaman yang telah dihapus atau sudah tidak ada.', + notfound_link_opens: 'Tautan ini akan membuka ${1} sebagai gantinya.', notfound: 'Halaman yang Anda cari tidak ada.', notfound_adaptive_title: 'Halaman tidak tersedia', notfound_adaptive: diff --git a/packages/gitbook/src/intl/translations/it.ts b/packages/gitbook/src/intl/translations/it.ts index 7260cb73b..b7e2f43b7 100644 --- a/packages/gitbook/src/intl/translations/it.ts +++ b/packages/gitbook/src/intl/translations/it.ts @@ -78,6 +78,7 @@ export const it: TranslationLanguage = { edit: 'Modifica', notfound_title: 'Pagina non trovata', notfound_link: 'Questo link punta a una pagina che è stata rimossa o non esiste più.', + notfound_link_opens: 'Al suo posto si apre ${1}.', notfound: 'La pagina che cerchi non esiste.', notfound_adaptive_title: 'Pagina non disponibile', notfound_adaptive: diff --git a/packages/gitbook/src/intl/translations/ja.ts b/packages/gitbook/src/intl/translations/ja.ts index 37c3e34dc..06f70b8dd 100644 --- a/packages/gitbook/src/intl/translations/ja.ts +++ b/packages/gitbook/src/intl/translations/ja.ts @@ -77,6 +77,7 @@ export const ja: TranslationLanguage = { edit: '編集', notfound_title: 'ページが見つかりません', notfound_link: 'このリンクは、削除されたか、もはや存在しないページを指しています。', + notfound_link_opens: '代わりに ${1} が開きます。', notfound: 'お探しのページは存在しません。', notfound_adaptive_title: 'ページにアクセスできません', notfound_adaptive: diff --git a/packages/gitbook/src/intl/translations/ko.ts b/packages/gitbook/src/intl/translations/ko.ts index f94fea69d..35fcdbeb1 100644 --- a/packages/gitbook/src/intl/translations/ko.ts +++ b/packages/gitbook/src/intl/translations/ko.ts @@ -77,6 +77,7 @@ export const ko: TranslationLanguage = { edit: '수정', notfound_title: '페이지를 찾을 수 없음', notfound_link: '이 링크는 삭제되었거나 더 이상 존재하지 않는 페이지를 가리킵니다.', + notfound_link_opens: '대신 ${1}(으)로 이동합니다.', notfound: '찾으시는 페이지가 존재하지 않습니다.', notfound_adaptive_title: '페이지에 접근할 수 없음', notfound_adaptive: '이 페이지는 존재할 수 있지만, 접근하려면 로그인해야 할 수 있습니다.', diff --git a/packages/gitbook/src/intl/translations/lt.ts b/packages/gitbook/src/intl/translations/lt.ts index 5d1b2da94..8b2980a59 100644 --- a/packages/gitbook/src/intl/translations/lt.ts +++ b/packages/gitbook/src/intl/translations/lt.ts @@ -76,6 +76,7 @@ export const lt: TranslationLanguage = { edit: 'Redaguoti', notfound_title: 'Puslapis nerastas', notfound_link: 'Ši nuoroda veda į puslapį, kuris buvo pašalintas arba nebeegzistuoja.', + notfound_link_opens: 'Vietoj to atidaromas: ${1}.', notfound: 'Puslapis, kurio ieškote, neegzistuoja.', notfound_adaptive_title: 'Puslapis nepasiekiamas', notfound_adaptive: diff --git a/packages/gitbook/src/intl/translations/lv.ts b/packages/gitbook/src/intl/translations/lv.ts index 96c391e1a..67197acb1 100644 --- a/packages/gitbook/src/intl/translations/lv.ts +++ b/packages/gitbook/src/intl/translations/lv.ts @@ -76,6 +76,7 @@ export const lv: TranslationLanguage = { edit: 'Rediģēt', notfound_title: 'Lapa nav atrasta', notfound_link: 'Šī saite norāda uz lapu, kas ir noņemta vai vairs nepastāv.', + notfound_link_opens: 'Tā vietā tiek atvērts: ${1}.', notfound: 'Meklētā lapa nepastāv.', notfound_adaptive_title: 'Lapa nav pieejama', notfound_adaptive: 'Šī lapa var pastāvēt, bet, iespējams, jums jāpierakstās, lai tai piekļūtu.', diff --git a/packages/gitbook/src/intl/translations/ms.ts b/packages/gitbook/src/intl/translations/ms.ts index fe47cefdf..0b29bb89a 100644 --- a/packages/gitbook/src/intl/translations/ms.ts +++ b/packages/gitbook/src/intl/translations/ms.ts @@ -76,6 +76,7 @@ export const ms: TranslationLanguage = { edit: 'Edit', notfound_title: 'Halaman tidak ditemui', notfound_link: 'Pautan ini menghala ke halaman yang telah dialih keluar atau tidak lagi wujud.', + notfound_link_opens: 'Pautan ini akan membuka ${1} sebagai gantinya.', notfound: 'Halaman yang anda cari tidak wujud.', notfound_adaptive_title: 'Halaman tidak tersedia', notfound_adaptive: diff --git a/packages/gitbook/src/intl/translations/nl.ts b/packages/gitbook/src/intl/translations/nl.ts index c7c231fdf..6243490eb 100644 --- a/packages/gitbook/src/intl/translations/nl.ts +++ b/packages/gitbook/src/intl/translations/nl.ts @@ -78,6 +78,7 @@ export const nl: TranslationLanguage = { edit: 'Bewerken', notfound_title: 'Pagina niet gevonden', notfound_link: 'Deze link verwijst naar een pagina die is verwijderd of niet meer bestaat.', + notfound_link_opens: 'In plaats daarvan wordt ${1} geopend.', notfound: 'De pagina die je zoekt, bestaat niet.', notfound_adaptive_title: 'Pagina niet beschikbaar', notfound_adaptive: diff --git a/packages/gitbook/src/intl/translations/no.ts b/packages/gitbook/src/intl/translations/no.ts index 97e9babfc..a4bb1b612 100644 --- a/packages/gitbook/src/intl/translations/no.ts +++ b/packages/gitbook/src/intl/translations/no.ts @@ -78,6 +78,7 @@ export const no: TranslationLanguage = { notfound_title: 'Siden ble ikke funnet', notfound_link: 'Denne lenken peker til en side som har blitt fjernet eller ikke lenger eksisterer.', + notfound_link_opens: 'Den åpner ${1} i stedet.', notfound: 'Siden du leter etter eksisterer ikke.', notfound_adaptive_title: 'Siden er ikke tilgjengelig', notfound_adaptive: 'Denne siden kan finnes, men du må kanskje logge inn for å få tilgang.', diff --git a/packages/gitbook/src/intl/translations/pl.ts b/packages/gitbook/src/intl/translations/pl.ts index c667a9a9d..011403838 100644 --- a/packages/gitbook/src/intl/translations/pl.ts +++ b/packages/gitbook/src/intl/translations/pl.ts @@ -76,6 +76,7 @@ export const pl: TranslationLanguage = { edit: 'Edytuj', notfound_title: 'Nie znaleziono strony', notfound_link: 'Ten link prowadzi do strony, która została usunięta lub już nie istnieje.', + notfound_link_opens: 'Zamiast tego otworzy się: ${1}.', notfound: 'Strona, której szukasz, nie istnieje.', notfound_adaptive_title: 'Strona niedostępna', notfound_adaptive: 'Ta strona może istnieć, ale dostęp do niej może wymagać zalogowania.', diff --git a/packages/gitbook/src/intl/translations/pt-br.ts b/packages/gitbook/src/intl/translations/pt-br.ts index 388087e12..0cf54a763 100644 --- a/packages/gitbook/src/intl/translations/pt-br.ts +++ b/packages/gitbook/src/intl/translations/pt-br.ts @@ -78,6 +78,7 @@ export const pt_br: TranslationLanguage = { edit: 'Editar', notfound_title: 'Página não encontrada', notfound_link: 'Este link aponta para uma página que foi removida ou não existe mais.', + notfound_link_opens: 'Em vez disso, ele abre ${1}.', notfound: 'A página que você está procurando não existe.', notfound_adaptive_title: 'Página indisponível', notfound_adaptive: diff --git a/packages/gitbook/src/intl/translations/pt.ts b/packages/gitbook/src/intl/translations/pt.ts index 393378be4..acc9aba15 100644 --- a/packages/gitbook/src/intl/translations/pt.ts +++ b/packages/gitbook/src/intl/translations/pt.ts @@ -77,6 +77,7 @@ export const pt: TranslationLanguage = { edit: 'Editar', notfound_title: 'Página não encontrada', notfound_link: 'Esta ligação aponta para uma página que foi removida ou já não existe.', + notfound_link_opens: 'Em vez disso, abre ${1}.', notfound: 'A página que procura não existe.', notfound_adaptive_title: 'Página indisponível', notfound_adaptive: diff --git a/packages/gitbook/src/intl/translations/ro.ts b/packages/gitbook/src/intl/translations/ro.ts index faf1d45b5..97291bccc 100644 --- a/packages/gitbook/src/intl/translations/ro.ts +++ b/packages/gitbook/src/intl/translations/ro.ts @@ -77,6 +77,7 @@ export const ro: TranslationLanguage = { edit: 'Editează', notfound_title: 'Pagina nu a fost găsită', notfound_link: 'Acest link indică o pagină care a fost eliminată sau nu mai există.', + notfound_link_opens: 'În schimb, se deschide ${1}.', notfound: 'Pagina pe care o cauți nu există.', notfound_adaptive_title: 'Pagina nu este disponibilă', notfound_adaptive: diff --git a/packages/gitbook/src/intl/translations/ru.ts b/packages/gitbook/src/intl/translations/ru.ts index 21a470236..3f0290644 100644 --- a/packages/gitbook/src/intl/translations/ru.ts +++ b/packages/gitbook/src/intl/translations/ru.ts @@ -78,6 +78,7 @@ export const ru: TranslationLanguage = { edit: 'Редактировать', notfound_title: 'Страница не найдена', notfound_link: 'Эта ссылка ведёт на страницу, которая была удалена или больше не существует.', + notfound_link_opens: 'Вместо этого откроется: ${1}.', notfound: 'Страница, которую вы ищете, не существует.', notfound_adaptive_title: 'Страница недоступна', notfound_adaptive: diff --git a/packages/gitbook/src/intl/translations/sk.ts b/packages/gitbook/src/intl/translations/sk.ts index c4824bfe7..bf592e29c 100644 --- a/packages/gitbook/src/intl/translations/sk.ts +++ b/packages/gitbook/src/intl/translations/sk.ts @@ -77,6 +77,7 @@ export const sk: TranslationLanguage = { edit: 'Upraviť', notfound_title: 'Stránka sa nenašla', notfound_link: 'Tento odkaz smeruje na stránku, ktorá bola odstránená alebo už neexistuje.', + notfound_link_opens: 'Namiesto toho sa otvorí: ${1}.', notfound: 'Stránka, ktorú hľadáte, neexistuje.', notfound_adaptive_title: 'Stránka nie je dostupná', notfound_adaptive: diff --git a/packages/gitbook/src/intl/translations/sl.ts b/packages/gitbook/src/intl/translations/sl.ts index 658ee2c38..34dfd4bf1 100644 --- a/packages/gitbook/src/intl/translations/sl.ts +++ b/packages/gitbook/src/intl/translations/sl.ts @@ -77,6 +77,7 @@ export const sl: TranslationLanguage = { edit: 'Uredi', notfound_title: 'Strani ni bilo mogoče najti', notfound_link: 'Ta povezava kaže na stran, ki je bila odstranjena ali ne obstaja več.', + notfound_link_opens: 'Namesto tega se odpre: ${1}.', notfound: 'Stran, ki jo iščete, ne obstaja.', notfound_adaptive_title: 'Stran ni na voljo', notfound_adaptive: 'Ta stran morda obstaja, vendar se boste za dostop morda morali prijaviti.', diff --git a/packages/gitbook/src/intl/translations/sv.ts b/packages/gitbook/src/intl/translations/sv.ts index efe4409a4..272f4fe5d 100644 --- a/packages/gitbook/src/intl/translations/sv.ts +++ b/packages/gitbook/src/intl/translations/sv.ts @@ -76,6 +76,7 @@ export const sv: TranslationLanguage = { edit: 'Redigera', notfound_title: 'Sidan hittades inte', notfound_link: 'Den här länken pekar på en sida som har tagits bort eller inte längre finns.', + notfound_link_opens: 'Den öppnar ${1} i stället.', notfound: 'Sidan du letar efter finns inte.', notfound_adaptive_title: 'Sidan är inte tillgänglig', notfound_adaptive: 'Sidan kan finnas, men du kan behöva logga in för att få åtkomst.', diff --git a/packages/gitbook/src/intl/translations/th.ts b/packages/gitbook/src/intl/translations/th.ts index c26e87cc8..019f62a06 100644 --- a/packages/gitbook/src/intl/translations/th.ts +++ b/packages/gitbook/src/intl/translations/th.ts @@ -75,6 +75,7 @@ export const th: TranslationLanguage = { edit: 'แก้ไข', notfound_title: 'ไม่พบหน้า', notfound_link: 'ลิงก์นี้ชี้ไปยังหน้าที่ถูกลบหรือไม่มีอยู่อีกต่อไป', + notfound_link_opens: 'ลิงก์นี้จะเปิด ${1} แทน', notfound: 'หน้าที่คุณกำลังค้นหาไม่มีอยู่', notfound_adaptive_title: 'หน้าไม่พร้อมใช้งาน', notfound_adaptive: 'หน้านี้อาจมีอยู่ แต่คุณอาจต้องเข้าสู่ระบบเพื่อเข้าถึง', diff --git a/packages/gitbook/src/intl/translations/tr.ts b/packages/gitbook/src/intl/translations/tr.ts index dd67763f9..5d1343c5c 100644 --- a/packages/gitbook/src/intl/translations/tr.ts +++ b/packages/gitbook/src/intl/translations/tr.ts @@ -76,6 +76,7 @@ export const tr: TranslationLanguage = { edit: 'Düzenle', notfound_title: 'Sayfa bulunamadı', notfound_link: 'Bu bağlantı kaldırılmış veya artık mevcut olmayan bir sayfaya işaret ediyor.', + notfound_link_opens: 'Bunun yerine ${1} açılır.', notfound: 'Aradığınız sayfa mevcut değil.', notfound_adaptive_title: 'Sayfa kullanılamıyor', notfound_adaptive: 'Bu sayfa mevcut olabilir, ancak erişmek için oturum açmanız gerekebilir.', diff --git a/packages/gitbook/src/intl/translations/uk.ts b/packages/gitbook/src/intl/translations/uk.ts index 85966ed2d..457a0af95 100644 --- a/packages/gitbook/src/intl/translations/uk.ts +++ b/packages/gitbook/src/intl/translations/uk.ts @@ -76,6 +76,7 @@ export const uk: TranslationLanguage = { edit: 'Редагувати', notfound_title: 'Сторінку не знайдено', notfound_link: 'Це посилання веде на сторінку, яку видалено або якої більше не існує.', + notfound_link_opens: 'Натомість відкриється: ${1}.', notfound: 'Сторінка, яку ви шукаєте, не існує.', notfound_adaptive_title: 'Сторінка недоступна', notfound_adaptive: 'Ця сторінка може існувати, але для доступу до неї може знадобитися вхід.', diff --git a/packages/gitbook/src/intl/translations/vi.ts b/packages/gitbook/src/intl/translations/vi.ts index c1c57e05f..9e642ab3e 100644 --- a/packages/gitbook/src/intl/translations/vi.ts +++ b/packages/gitbook/src/intl/translations/vi.ts @@ -76,6 +76,7 @@ export const vi: TranslationLanguage = { edit: 'Chỉnh sửa', notfound_title: 'Không tìm thấy trang', notfound_link: 'Liên kết này trỏ đến một trang đã bị xóa hoặc không còn tồn tại.', + notfound_link_opens: 'Thay vào đó, liên kết sẽ mở ${1}.', notfound: 'Trang bạn đang tìm kiếm không tồn tại.', notfound_adaptive_title: 'Trang không khả dụng', notfound_adaptive: 'Trang này có thể tồn tại, nhưng bạn có thể cần đăng nhập để truy cập.', diff --git a/packages/gitbook/src/intl/translations/yue.ts b/packages/gitbook/src/intl/translations/yue.ts index 93450ca4f..27ffc2ec4 100644 --- a/packages/gitbook/src/intl/translations/yue.ts +++ b/packages/gitbook/src/intl/translations/yue.ts @@ -74,6 +74,7 @@ export const yue: TranslationLanguage = { edit: '編輯', notfound_title: '搵唔到頁面', notfound_link: '呢條連結指向嘅頁面已被移除或已經唔存在。', + notfound_link_opens: '會改為開啟 ${1}。', notfound: '你搵緊嘅頁面唔存在。', notfound_adaptive_title: '頁面無法使用', notfound_adaptive: '呢個頁面可能存在,但你可能需要登入先可以存取。', diff --git a/packages/gitbook/src/intl/translations/zh-tw.ts b/packages/gitbook/src/intl/translations/zh-tw.ts index 5141e5ff9..c40362396 100644 --- a/packages/gitbook/src/intl/translations/zh-tw.ts +++ b/packages/gitbook/src/intl/translations/zh-tw.ts @@ -74,6 +74,7 @@ export const zh_tw: TranslationLanguage = { edit: '編輯', notfound_title: '找不到頁面', notfound_link: '此連結指向的頁面已被移除或不再存在。', + notfound_link_opens: '將改為開啟 ${1}。', notfound: '您要尋找的頁面不存在。', notfound_adaptive_title: '頁面無法使用', notfound_adaptive: '此頁面可能存在,但您可能需要登入才能存取。', diff --git a/packages/gitbook/src/intl/translations/zh.ts b/packages/gitbook/src/intl/translations/zh.ts index 552613251..9c436156f 100644 --- a/packages/gitbook/src/intl/translations/zh.ts +++ b/packages/gitbook/src/intl/translations/zh.ts @@ -75,6 +75,7 @@ export const zh: TranslationLanguage = { edit: '编辑', notfound_title: '页面未找到', notfound_link: '此链接指向已被删除或不再存在的页面。', + notfound_link_opens: '将改为打开 ${1}。', notfound: '您要找的页面不存在。', notfound_adaptive_title: '页面无法访问', notfound_adaptive: '该页面可能存在,但您可能需要登录后才能访问。', diff --git a/packages/gitbook/src/lib/references.test.ts b/packages/gitbook/src/lib/references.test.ts index 4458b4bdd..710b49d4d 100644 --- a/packages/gitbook/src/lib/references.test.ts +++ b/packages/gitbook/src/lib/references.test.ts @@ -805,5 +805,16 @@ describe('resolveContentRef for application URLs into the site', () => { ); expect(fallback?.href).toBe('/analytics-alerts'); + expect(fallback?.text).toBe('Alerts'); + }); + + it('keeps the application fallback for a page ref into a space outside the site', () => { + const fallback = resolveContentRefFallback( + { kind: 'page', space: 'space-elsewhere', page: 'page-deleted' }, + context + ); + + expect(fallback?.href).toBe('https://app.gitbook.com/s/space-elsewhere'); + expect(fallback?.text).toBe('space'); }); }); diff --git a/packages/gitbook/src/lib/references.tsx b/packages/gitbook/src/lib/references.tsx index b77d14588..490d1d3f4 100644 --- a/packages/gitbook/src/lib/references.tsx +++ b/packages/gitbook/src/lib/references.tsx @@ -434,9 +434,10 @@ export function resolveContentRefFallback( ): ResolvedContentRef | null { if ('space' in contentRef && contentRef.space) { const linker = context ? getLinkerForSpaceInSite(context, contentRef.space) : null; + const inSite = context ? getBestTargetSpaceFromSite(context, contentRef.space) : undefined; return { href: linker?.toPathInSpace('') ?? getGitBookAppHref(`/s/${contentRef.space}`), - text: 'space', + text: linker && inSite ? getSpaceRefText(inSite, context?.locale) : 'space', active: false, }; }