FrameworkJavaScript
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.
Import
TypeScript
import { PageLink } from '@bloklabs/core/tools';Save Data
TypeScript
interface PageLinkData {
pageId: string;
}JSON
{
"id": "ref001",
"type": "page-link",
"data": { "pageId": "p1" }
}Usage Example
TypeScript
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}`,
subscribe: (pageId, onChange) => myApi.subscribePage(pageId, onChange),
},
},
},
});