Page link block: reference an existing page
A non-owning reference to a host page. It saves only data.pageId and never creates or owns a page. Use it for links to an existing page; an owning page block is the page tree edge.
Register PageLink with the same authorized PageConfig as Page. Missing or denied metadata shows a neutral or locked label without the page title or URL.
With search in its config, the "/" menu offers Link to page. It opens a page list with its own search field. Picking a page inserts the link; Escape inserts nothing.
Import
import { PageLink } from '@bloklabs/core/tools';Configuration
| Option | Type | Default | Description |
|---|---|---|---|
search | (query: string) => Promise<readonly PageSearchResult[]> | undefined | Shows Link to page in the "/" menu and lists the pages to pick from. Results work as in "/" reads this tool's config, and |
Save Data
interface PageLinkData {
pageId: string;
}{
"id": "ref001",
"type": "page-link",
"data": { "pageId": "p1" }
}Usage Example
import { Blok } from '@bloklabs/core';
import { PageLink } from '@bloklabs/core/tools';
const editor = new Blok({
holder: 'editor',
tools: {
'page-link': {
class: PageLink,
config: {
resolve: (pageId) => myApi.getAuthorizedPageInfo(pageId),
href: (pageId) => `/pages/${pageId}`,
// Shows Link to page in the "/" menu.
search: (query) => myApi.searchAccessiblePages(query),
subscribe: (pageId, onChange) => myApi.subscribePage(pageId, onChange),
},
},
},
});