Skip to content

Commit dab4712

Browse files
feat(console): the All documentation page has the console's top bar, groups its books by app, and searches every article (#36027)
<!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuBsvXiyTDYggWLQFR1qKw49)_ Fixes #35424 repo:objectstack#1 · os-sales · session_01L6bhgTo4iDVWE2AcWkPm77 · Area: b1-CX ## 维护者速读 - 用户看到的变化:「全部文档」页(以及它下面的手册和文章页)换成和首页一样的顶栏「ObjectOS / 文档」,带搜索、通知、助手和头像菜单,可以直接回到任何应用;手册按应用分组,组名就是应用启动器里的名字;卡片上不再出现包 id;副标题和「9 篇」这样的计数跟随当前语言;页面右上角新增「搜索全部文档」,按标题、摘要和正文搜所有文章,结果里高亮命中的词,点开直接进到文章所在的手册。 - 系统包(如「系统设置」)的手册只挂在它的应用下面:成员的应用列表里没有这个应用,这页就不列它。这只是「列不列」,谁能读文档仍由服务端的受众规则决定,和以前一样。 - 最坏情况:只影响显示。全文搜索第一次输入时多一次 `GET /meta/doc?include=content` 请求(走和列表相同的受众规则);撤回这个 PR 即恢复原样。 - 需要 Sales 做的:无。 ## What changes The "All documentation" half of #35424 (its items 6–9, design figure 26), plus three notes carried from #36000. 6. **The console's top bar on every portal page.** `/docs`, `/docs/<book>` and `/docs/<book>/<article>` now render inside Home's frame (`DefaultHomeLayout`, under the same organization / permissions layout as `/home`). The bar reads 「<product> / Documentation」 (a new `docs` variant of `AppHeader`; the crumb links to `/docs`) and keeps the centred search, inbox, assistant and avatar menu. The portal's own 「Documentation / <title>」 strip is gone (`DocShell` draws no bar off an app). 7. **Books grouped by app** (`groupBooksByApp`, `docs-index.ts`). A book goes under the first app whose navigation links to it (a `doc` entry naming the book or one of its articles, in `navigation`, nested `children` or `areas`, so a module's navigation contributions count), else under the first app of its package; books no app carries are listed last under 「Other documentation」. Groups are named as the launcher names the app (`useServedAppLabel`). **The subtitle and the counts read the session language** (「9 篇」), through new `help.*` keys with per-locale plural forms. 8. **No package id on any card.** A package's docs with no authored book are named by their app. A platform package's books (`com.objectstack.*`) are listed only under an app in the member's list that carries them (one linking them, else their own package's app), never under 「Other documentation」, so a member whose app list (`/meta/app`, already filtered by the server) has no such app does not see them listed. An implicit book is named by its own package's app, never by another app that links it. This is what the page lists, not who may read a doc: the server's audience gate decides that, as before. 9. **「Search all documentation」** (`searchDocs`, `useDocContents`). A search field on the page matches every listed article's title, summary and body (every word must match; title ranks above summary above body), and lists the matches with the words marked in context; each opens the article in its own book. Mermaid source and markup are not searched. The bodies are asked once, the first time the reader types (`GET /meta/doc?include=content`, which the server answers through the same audience gate as the slim list), and held for the page's life: one read of every listed doc's body per visit that searches, and none for a visit that does not. A server-side search shared with the MCP doc door is the follow-up if doc volume grows. Every match is listed and counted (no cap). The query stays in the URL (`?q=`). The label differs from the reader column's 「Search docs」. Notes from #36000: - **N3:** a hand-typed `/docs/<book A>/<article of book B>` now redirects to the article in its own book; with no book that holds it, the reader draws no previous / next pager instead of both ends at once (`bookHoldsArticle`). - The portal reader passes `backLink={!docsNav}` to `DocShell`, so inside an app an article whose book is in no package keeps its 「← Back to <app>」 link. `@objectstack/client`: `meta.getItems(type, { include })` (both the unscoped and the environment-scoped client) sends `?include=`; leaving it out sends nothing, as before. The options type is exported as `MetaItemsListOptions`. `@object-ui/app-shell`: `AppHeader` takes a `docs` variant; `DefaultHomeLayout` takes `variant`. ## Why The maintainer's topic #34571, card #35424, figure 26: the "All docs" page had no way back to the apps (its own one-line bar), listed books flat with package ids (`com.objectstack.setup`), an English subtitle and counts under a Chinese session, the Setup book for every member, and no way to search across books. ## Verification - Browser, against the showcase app (`objectstack dev --fresh`, console on vite), zh-CN, dark, 1280 × 800 and 375 × 812, `/docs`, `/docs?q=Markdown`, `/docs/manual`: - before: one bar 「文档」 with no search or menus; two flat cards, the second 「Setup」 with `com.objectstack.setup` under it; 「Books and guides from your installed packages.」 and 「8 articles」 in English; no search. - after: the bar 「ObjectOS 预览版 / 文档」 with search, inbox, help and avatar; groups 「功能展示」 (示例手册, 8 篇) and 「系统设置」 (系统设置, 1 篇); subtitle 「已安装应用自带的使用手册。」; 「Markdown」 finds 3 articles, each with its book and the word marked in the snippet; the reader under the same bar. At 375 px the bar folds to its phone form and the search sits under the title. - Screenshots (before / after, both widths) are kept with the card's evidence for the reviewer. - Tests: - `docs-index.test.ts` (new): grouping by link, by package, the ungrouped group, a `doc` link counting as linking its book, platform books only under an app in the list that carries them (and named by their own app), no package id line; search word logic and ranking, listed-books filter, a hit naming its book as the card does, every match answered, no diagram source or markup, snippet marking, CJK without spaces. - `docs-portal.test.tsx`: the real `DocsIndex` under the docs routes — groups and labels, the platform rule, search (URL, one content read for several queries, the article opened in its own book), search limited to listed books, the label differing from 「Search docs」, the N3 redirect with its control; the earlier collision pin now expects the redirect. - `AppHeader.centeredSearch-12472`, `AppHeader.aboutBuild-12970`, `AppHeader.searchTriggerNeedsPalette-11912`: the `docs` variant (centred search, the crumb to `/docs`, the about item, the palette gate); the home bar's control has no crumb. - `client.test.ts`: `include` sent as `?include=` on both getItems, nothing when left out. - `App.docsPortalLazy.test.tsx`: the portal stays lazy inside its new frame. - `vitest`: `apps/console` docs files (64 tests), `packages/i18n` in full (parity, base keys, CLDR plural categories per pack), the app-shell layout and home tests, `packages/client` (223 tests): all passed. `tsc` for console, app-shell (with `tsconfig.test.json`) and client; `check:i18n-keys`; `eslint` over the changed files: 0 errors, no new warnings. zh-Hant regenerated with `gen:zh-hant`. - `overlap-check.mjs`: clean against `origin/main` and the five open PRs sharing the locale files or `AppHeader.tsx` (#35968, #35994, #36018, #36024, #36026). Clause-②: yes (widening) — @objectstack/client `meta.getItems` takes an optional `include` (`'content' | 'grants'`, sent as `?include=`) and exports its options type `MetaItemsListOptions`; @object-ui/i18n adds nine help.* keys (two of them plural, with their per-locale forms); nothing removed Metadata-protocol: none Follow-ups (not in this PR): #36029 — give Setup's own books an audience, so a member without `setup.access` cannot read them, not only does not see them listed (card #35424 item 8 reads "only admins see it"; this PR makes it a listing rule). ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (No spec change.) - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: n/a. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgTo4iDVWE2AcWkPm77 <!-- signed: repo:objectstack#1 · os-sales · session_01L6bhgTo4iDVWE2AcWkPm77 --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent c00be39 commit dab4712

32 files changed

Lines changed: 1270 additions & 154 deletions

‎.changeset/35424-all-docs-page.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@objectstack/client': patch
3+
'@object-ui/console': patch
4+
'@object-ui/app-shell': patch
5+
'@object-ui/i18n': patch
6+
---
7+
8+
feat(console): the 「All documentation」 page has the console's top bar, groups its books by app, and searches every article
9+
10+
Clause-②: yes (widening) — @objectstack/client `meta.getItems` takes an optional `include` (`'content' | 'grants'`, sent as `?include=`) and exports its options type `MetaItemsListOptions`; @object-ui/i18n adds nine help.* keys (two of them plural, with their per-locale forms); nothing removed
11+
Metadata-protocol: none
12+
13+
- **The console's top bar on every portal page.** `/docs`, a book (`/docs/<book>`) and an article (`/docs/<book>/<article>`) are drawn in Home's frame, whose bar reads 「<product> / Documentation」 (the crumb links to the portal's index) and carries the search, the inbox, the assistant and the avatar menu, so the reader can go back to any app. The portal's own 「Documentation / <title>」 strip is gone.
14+
- **Books grouped by app.** The page lists each app's books under the app's name, as the launcher names it: a book goes under the first app whose navigation links to it (a module's navigation contributions included), else under its package's app; books no app carries are listed last under 「Other documentation」. No card shows a package id; a package's docs with no authored book are named by their app. A platform package's books (`com.objectstack.*`, such as Setup's) are listed only under an app in the member's list that carries them, never under 「Other documentation」, so they are not listed for a member whose app list has no such app. This is what the page lists, not who may read a doc: the server's audience gate decides that, as before.
15+
- **The subtitle and the counts read the session language** (「9 篇」, not 「9 articles」).
16+
- **「Search all documentation」.** A search field on the page searches every listed article's title, summary and body, and lists the matches with the words marked in context; each opens the article in its own book. The bodies are asked once, the first time the reader searches (`GET /meta/doc?include=content`, through the same audience gate as the list). The query stays in the URL (`?q=`).
17+
- **A hand-typed article URL whose book does not hold the article** (`/docs/<book A>/<article of book B>`) now opens the article in its own book; with no book that holds it, the article draws no previous/next pager instead of showing both ends at once. Inside an app, an article whose book is in no package now keeps its 「← Back to <app>」 link.
18+
19+
`@objectstack/client`: `client.meta.getItems(type, { include })` and the environment-scoped `meta.getItems` send `?include=`; leaving it out sends nothing, as before. `@object-ui/app-shell`: `AppHeader` takes a `docs` variant and `DefaultHomeLayout` a `variant` prop for it.

‎packages/client/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ await client.connect();
230230
// Discovery & Metadata
231231
await client.meta.getTypes(); // List metadata types
232232
await client.meta.getItems('object'); // List all objects
233+
await client.meta.getItems('doc', { include: 'content' }); // List docs WITH their bodies (the list omits them by default)
233234
await client.meta.getItem('object', 'contact'); // Get specific object
234235

235236
// Data Operations

‎packages/client/src/client.test.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,28 @@ describe('ObjectStackClient', () => {
209209
]);
210210
});
211211

212+
it('sends `include` as `?include=`, on the unscoped and the environment surface (the doc list keeps its bodies)', async () => {
213+
const fetchMock = vi.fn().mockResolvedValue({
214+
ok: true,
215+
json: async () => ({ type: 'doc', items: [{ name: 'intro', content: '# Intro' }] }),
216+
});
217+
const client = new ObjectStackClient({ baseUrl: 'http://localhost:3000', fetch: fetchMock });
218+
219+
await client.meta.getItems('doc', { include: 'content' });
220+
await client.meta.getItems('doc', { packageId: 'com.acme', include: 'content' });
221+
await client.environment('env_1').meta.getItems('doc', { include: 'content' });
222+
// Left out, nothing is sent: the list stays the slim default.
223+
await client.meta.getItems('doc');
224+
225+
const urls = fetchMock.mock.calls.map((c) => String(c[0]));
226+
expect(urls).toEqual([
227+
'http://localhost:3000/api/v1/meta/doc?include=content',
228+
'http://localhost:3000/api/v1/meta/doc?package=com.acme&include=content',
229+
'http://localhost:3000/api/v1/environments/env_1/meta/doc?include=content',
230+
'http://localhost:3000/api/v1/meta/doc',
231+
]);
232+
});
233+
212234
it('should get metadata item by type and name', async () => {
213235
// The server's body is the spec-declared `GetMetaItemResponseSchema`
214236
// envelope — `{ type, name, item }`, with the metadata document under

‎packages/client/src/index.ts‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,19 @@ export type { QualifiedAddressOptions } from './package-address';
235235
*/
236236
export type ApiRouteType = keyof ApiRoutes;
237237

238+
/**
239+
* The options of `meta.getItems` (`GET /meta/:type`). `packageId` scopes the
240+
* list to one package (`?package=`); `names` narrows it to those items in one
241+
* request (`?names=a,b,c`); `include` asks for what the list omits by default
242+
* (`?include=`): `'content'` keeps each `doc`'s body (ADR-0046), `'grants'`
243+
* adds each `position`'s grants.
244+
*/
245+
export interface MetaItemsListOptions {
246+
packageId?: string;
247+
names?: readonly string[];
248+
include?: 'content' | 'grants';
249+
}
250+
238251
/**
239252
* [#30205] `security.assignedWork.count`'s answer: per object and user field,
240253
* how many records hold the user, as the caller can read them.
@@ -2083,12 +2096,16 @@ export class ObjectStackClient {
20832096
* (sent as `?names=a,b,c`). A name that matches no item is simply absent
20842097
* from the answer. An empty `names` array is sent as an empty filter,
20852098
* which the server refuses with `400`; leave `names` out to list every item.
2099+
* `include` asks for what the list leaves out by default (`?include=`):
2100+
* `'content'` keeps each `doc`'s body (ADR-0046), `'grants'` adds each
2101+
* `position`'s grants.
20862102
*/
2087-
getItems: async (type: string, options?: { packageId?: string; names?: readonly string[] }): Promise<GetMetaItemsResponse> => {
2103+
getItems: async (type: string, options?: MetaItemsListOptions): Promise<GetMetaItemsResponse> => {
20882104
const route = this.getRoute('metadata');
20892105
const params = new URLSearchParams();
20902106
if (options?.packageId) params.set('package', options.packageId);
20912107
if (options?.names !== undefined) params.set('names', options.names.join(','));
2108+
if (options?.include) params.set('include', options.include);
20922109
const qs = params.toString();
20932110
const url = `${this.baseUrl}${route}/${type}${qs ? `?${qs}` : ''}`;
20942111
const res = await this.fetch(url);
@@ -8696,11 +8713,12 @@ export class ScopedEnvironmentClient {
86968713
const res = await this.parent._fetch(this.metaUrl(''));
86978714
return this.parent._unwrap<GetMetaTypesResponse>(res);
86988715
},
8699-
/** The unscoped surface's `getItems`, `names` included (one `?names=a,b,c` request). */
8700-
getItems: async (type: string, options?: { packageId?: string; names?: readonly string[] }): Promise<GetMetaItemsResponse> => {
8716+
/** The unscoped surface's `getItems`, `names` and `include` included (one `?names=a,b,c` request). */
8717+
getItems: async (type: string, options?: MetaItemsListOptions): Promise<GetMetaItemsResponse> => {
87018718
const params = new URLSearchParams();
87028719
if (options?.packageId) params.set('package', options.packageId);
87038720
if (options?.names !== undefined) params.set('names', options.names.join(','));
8721+
if (options?.include) params.set('include', options.include);
87048722
const qs = params.toString();
87058723
const res = await this.parent._fetch(this.metaUrl(`/${type}${qs ? `?${qs}` : ''}`));
87068724
return this.parent._unwrap<GetMetaItemsResponse>(res);

‎ui/apps/console/src/App.tsx‎

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,20 @@ function HomeRoute() {
213213
);
214214
}
215215

216+
/**
217+
* The docs portal's frame (objectstack#35424): Home's layout with the docs bar,
218+
* around the lazily loaded docs layout, so the bar is up while the portal's
219+
* chunk loads.
220+
*/
221+
function DocsPortalRoute() {
222+
const { user } = useAuth();
223+
return (
224+
<DefaultHomeLayout userId={user?.id} variant="docs">
225+
<Suspense fallback={<LoadingScreen />}><DocsLayout /></Suspense>
226+
</DefaultHomeLayout>
227+
);
228+
}
229+
216230
export function App() {
217231
/**
218232
* The console's ONE upload destination, mounted above `ConsoleShell` so it
@@ -351,26 +365,6 @@ export function App() {
351365
* layer too late for a capability whose declared meaning is
352366
* "Enter the Studio metadata-design surfaces". */}
353367
{studioRoutes}
354-
{/* Package documentation (ADR-0046): a platform-level portal
355-
* lists every installed `doc` (grouped by package), and one
356-
* viewer route renders any item; cross-references between docs
357-
* resolve to that same viewer route. Both are app-independent. */}
358-
{/* Docs portal (ADR-0046 §6). The layout fetches book + doc once
359-
* and shares it with every child route via context. Children:
360-
* index → book index
361-
* :slug → a book landing, or a flat-doc permalink that
362-
* redirects to its canonical /docs/<book>/<name>
363-
* :slug/:name → in-book reader (doc identity stays single-
364-
* coordinate; the book segment is derived nav). */}
365-
<Route path="/docs" element={
366-
<ProtectedRoute>
367-
<Suspense fallback={<LoadingScreen />}><DocsLayout /></Suspense>
368-
</ProtectedRoute>
369-
}>
370-
<Route index element={<Suspense fallback={<LoadingScreen />}><DocsIndex /></Suspense>} />
371-
<Route path=":slug" element={<Suspense fallback={<LoadingScreen />}><DocsSlug /></Suspense>} />
372-
<Route path=":slug/:name" element={<Suspense fallback={<LoadingScreen />}><DocPage /></Suspense>} />
373-
</Route>
374368
{/* objectui#12700 — Home and every app share ONE
375369
* `/auth/me/permissions` source. A pathless layout route is their
376370
* common ancestor: its element (auth, the shell, the permissions
@@ -419,6 +413,25 @@ export function App() {
419413
</RequireOrganization>
420414
}>
421415
<Route path="/home" element={<HomeRoute />} />
416+
{/* Package documentation (ADR-0046 §6): a platform-level portal
417+
* lists every installed `doc` (grouped by the launcher's apps),
418+
* and one viewer route renders any item; cross-references
419+
* between docs resolve to that same viewer route. App-independent,
420+
* so it is drawn in Home's frame with the docs bar (`docs`
421+
* variant: 「PRODUCT / Documentation」), under this layout for
422+
* the same `/auth/me/permissions` answer Home reads
423+
* (objectstack#35424). The layout fetches book + doc once and
424+
* shares it with every child route via context. Children:
425+
* index → book index
426+
* :slug → a book landing, or a flat-doc permalink that
427+
* redirects to its canonical /docs/<book>/<name>
428+
* :slug/:name → in-book reader (doc identity stays single-
429+
* coordinate; the book segment is derived nav). */}
430+
<Route path="/docs" element={<DocsPortalRoute />}>
431+
<Route index element={<Suspense fallback={<LoadingScreen />}><DocsIndex /></Suspense>} />
432+
<Route path=":slug" element={<Suspense fallback={<LoadingScreen />}><DocsSlug /></Suspense>} />
433+
<Route path=":slug/:name" element={<Suspense fallback={<LoadingScreen />}><DocPage /></Suspense>} />
434+
</Route>
422435
<Route path="/apps/:appName/*" element={<AppContent />} />
423436
{/* Internal authed form — same renderer as `/f/:slug`, different
424437
* submit path, and (objectui#4109) rendered INSIDE the console

‎ui/apps/console/src/__tests__/App.docsPortalLazy.test.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ vi.mock('@object-ui/app-shell', async (importOriginal) => ({
9494
// is pinned by `packages/app-shell/src/chrome/RedirectWithSplash.test.tsx`.
9595
RedirectWithSplash: stub('redirect-with-splash'),
9696
RequireAiSurface: passthrough,
97+
// objectstack#35424: `/docs` sits under the organization gate with `/home` and `/apps`.
98+
RequireOrganization: passthrough,
9799
SystemRedirect: () => null,
98100
DefaultHomeLayout: passthrough,
99101
DefaultHomePage: stub('home-page'),

‎ui/apps/console/src/pages/BookPage.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ import { resolveBookTree, bookSlug, firstDoc } from './book-nav';
2323
* beneath the heading. Shared by `DocsSlug` (a segment the member's lists do not
2424
* answer) and `DocPage` (the reader).
2525
*/
26-
export function DocRefusal({ name, message }: { name?: string; message?: string }) {
26+
export function DocRefusal({ message }: { message?: string }) {
2727
return (
28-
<DocShell breadcrumb={name}>
28+
<DocShell>
2929
<div className="mx-auto flex max-w-3xl flex-col items-center gap-3 p-10 text-center">
3030
<Lock className="h-10 w-10 text-muted-foreground" />
3131
<h1 className="text-lg font-semibold">You do not have access to this documentation</h1>
@@ -68,7 +68,7 @@ export default function BookPage() {
6868

6969
// Unknown book, or a book with no readable docs yet.
7070
return (
71-
<DocShell breadcrumb={found ? (found.label ?? slug) : slug}>
71+
<DocShell>
7272
<div className="mx-auto flex max-w-3xl flex-col items-center gap-3 p-10 text-center">
7373
{found ? (
7474
<>

‎ui/apps/console/src/pages/DocPage.tsx‎

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { DocsNav, type DocsNavBook } from './DocsNav';
2020
import { DocRefusal } from './BookPage';
2121
import { useBookData } from './use-book-data';
2222
import { useActiveHeading } from './useActiveHeading';
23-
import { articleNeighbours, type BookArticle } from './docs-reading';
23+
import { articleNeighbours, bookHoldsArticle, type BookArticle } from './docs-reading';
2424
import { resolveBookTree, bookSlug, bookNamedBy, homeBook, labelUncategorized, pkgOfBook, type ResolvedBook } from './book-nav';
2525

2626
interface DocItem {
@@ -282,11 +282,28 @@ export default function DocPage() {
282282
// context. Only a segment NO book answers by slug is consulted, so every
283283
// reader URL that finds its book today keeps its answer.
284284
const namedBook = useMemo(() => (slug && !resolvedBook ? bookNamedBy(slug, books) : null), [slug, resolvedBook, books]);
285+
// objectstack#35424 — a reader URL whose book does not hold its doc (a
286+
// hand-typed `/docs/BOOK_A/DOC_OF_BOOK_B`) reads in the doc's own book: it is
287+
// redirected there once the doc has loaded, so the column, the path above
288+
// the article and the pager all describe the book the article is in. With
289+
// no book that holds it, the page draws no pager (see below).
290+
const inBook = resolvedBook ? bookHoldsArticle(resolvedBook, name) : false;
291+
const ownBook = useMemo(() => {
292+
if (state !== 'ready' || doc?.name !== name || !name || !resolvedBook || inBook) return null;
293+
const home = homeBook(name, books, allDocs, appName);
294+
if (!home || bookSlug(home) === slug) return null;
295+
const resolved = resolveBookTree(home, allDocs, undefined, authoredBooks);
296+
return bookHoldsArticle(resolved, name) ? home : null;
297+
}, [state, doc, name, resolvedBook, inBook, books, allDocs, authoredBooks, appName, slug]);
285298

286299
if (namedBook && name) {
287300
return <Navigate to={{ pathname: `${base}/${bookSlug(namedBook)}/${name}`, hash }} replace />;
288301
}
289302

303+
if (ownBook && name) {
304+
return <Navigate to={{ pathname: `${base}/${bookSlug(ownBook)}/${name}`, hash }} replace />;
305+
}
306+
290307
if (state === 'loading') {
291308
return (
292309
<div className="flex h-full items-center justify-center p-10 text-muted-foreground">
@@ -297,7 +314,7 @@ export default function DocPage() {
297314

298315
if (state === 'missing') {
299316
return (
300-
<DocShell breadcrumb={name}>
317+
<DocShell>
301318
<div className="mx-auto flex max-w-3xl flex-col items-center gap-3 p-10 text-center">
302319
<FileQuestion className="h-10 w-10 text-muted-foreground" />
303320
<h1 className="text-lg font-semibold">Documentation not found</h1>
@@ -311,12 +328,12 @@ export default function DocPage() {
311328
}
312329

313330
if (state === 'refused') {
314-
return <DocRefusal name={name} message={errorMessage} />;
331+
return <DocRefusal message={errorMessage} />;
315332
}
316333

317334
if (state === 'conflict') {
318335
return (
319-
<DocShell breadcrumb={name}>
336+
<DocShell>
320337
<div className="mx-auto flex max-w-3xl flex-col items-center gap-3 p-10 text-center">
321338
<Layers className="h-10 w-10 text-muted-foreground" />
322339
<h1 className="text-lg font-semibold">
@@ -357,7 +374,7 @@ export default function DocPage() {
357374

358375
if (state === 'error') {
359376
return (
360-
<DocShell breadcrumb={name}>
377+
<DocShell>
361378
<div className="mx-auto flex max-w-3xl flex-col items-center gap-3 p-10 text-center">
362379
<AlertCircle className="h-10 w-10 text-destructive" />
363380
<h1 className="text-lg font-semibold">Failed to load documentation</h1>
@@ -381,7 +398,7 @@ export default function DocPage() {
381398
const docsLabel = t('help.documentation', { defaultValue: 'Documentation' });
382399

383400
return (
384-
<DocShell breadcrumb={doc?.label ?? name} backLink={false}>
401+
<DocShell backLink={!docsNav}>
385402
{/* objectstack#35424 — the docs column is the page's one navigation.
386403
* Inside an app it sits where the app menu would, full height beside
387404
* the article; on narrow screens it folds into a disclosure above it. */}
@@ -441,7 +458,7 @@ export default function DocPage() {
441458
/>
442459
</MermaidEnlargeContext.Provider>
443460
</article>
444-
{resolvedBook ? (
461+
{resolvedBook && inBook ? (
445462
<ArticlePager
446463
previous={neighbours.previous}
447464
next={neighbours.next}

0 commit comments

Comments
 (0)