diff --git a/docs/integrations/configurations.md b/docs/integrations/configurations.md index ab07bea72..3920d52ef 100644 --- a/docs/integrations/configurations.md +++ b/docs/integrations/configurations.md @@ -98,6 +98,7 @@ The scopes your integration has permissions for. - site:script:inject ## Internal scope - see note below - site:script:cookies ## Internal scope - see note below - site:visitor:auth ## Enable workflows related to authenticated access + - site:visitor:claims ## Expose visitor claims to webframes - site:adaptive:read ## Read claims available from Adaptive Content - site:adaptive:write ## Write claims avaiable to Adaptive Content # OpenAPI diff --git a/docs/integrations/contentkit/interactivity.md b/docs/integrations/contentkit/interactivity.md index 932d6da6c..475ced95f 100644 --- a/docs/integrations/contentkit/interactivity.md +++ b/docs/integrations/contentkit/interactivity.md @@ -91,6 +91,27 @@ window.addEventListener("message", (event) => { }); ``` +## Page and visitor context + +GitBook injects contextual information about the current site into the webframe `state`, alongside the values you bind through the `data` prop: + +- `state.page` — the current page as `{ id, path, title }`. Always available. +- `state.visitor` — the visitor claims, when the integration has the `site:visitor:claims` [scope](../configurations.md#scopes). + +This context is delivered client-side through the same `message` event as your bound `data`, so it does not change how the integration block is cached: + +```js +window.addEventListener("message", (event) => { + const state = event.data?.state; + if (!state) return; + + if (state.page) { + const { id, path, title } = state.page; + // e.g. build a link to a sibling page from `path` + } +}); +``` + ## Navigating to another page A webframe can navigate the reader to another page in the site by posting a `@webframe.navigate` action. The `path` is resolved relative to the site root (the part after your site's base URL), so it can point to a page in any section or space of the site, and navigation always stays within it. You can also pass an optional `anchor` to scroll to a heading within the target page: diff --git a/docs/integrations/development/contentkit/reference.md b/docs/integrations/development/contentkit/reference.md index 3e5abd076..e73b98977 100644 --- a/docs/integrations/development/contentkit/reference.md +++ b/docs/integrations/development/contentkit/reference.md @@ -264,7 +264,7 @@ If you need a copy button, only add it when your integration has a supported way | `buttons` | `Array