Reads published pages such as "About" or "Contact", available as lynkow.pages. A page holds structured data resolved by the API instead of a rich text body. With cache: true, responses are cached for 5 minutes.

Access via: lynkow.pages

Methods

5 methods

clearCache

TypeScript
clearCache(): void

Clears every cached page response held by the client. Call it when a page.* webhook arrives so the next read fetches fresh data.

Returns: void

TypeScript
lynkow.pages.clearCache()

getByPath

TypeScript
getByPath(path: string, options?: BaseRequestOptions): Promise<Page | ResolveRedirectResponse>

Fetches a published page by its public URL path, which may be nested, such as /services/consulting. The full page has the same data as getBySlug(). Resolves to a ResolveRedirectResponse instead of a page when a redirect rule covers the path: narrow the result with isRedirectResponse() before reading page fields. A leading locale segment such as /fr/about selects that locale unless a locale option is set. With cache: true, cached for 5 minutes. Throws LynkowError NOT_FOUND when no page and no redirect match the path, and BAD_REQUEST with apiCode VALIDATION_FIELD_REQUIRED for an empty path.

Parameter

Type

Description

path

string

The public URL path, such as '/services/consulting'.

options

BaseRequestOptions

Request options. locale selects the translation, fallback: false refuses a fallback.

Returns: Promise<Page | ResolveRedirectResponse>

TypeScript
import { isRedirectResponse } from 'lynkow'

// Resolve a page from the current URL
const page = await lynkow.pages.getByPath('/services/consulting')
if (isRedirectResponse(page)) {
  // Send the visitor to page.redirect.target with page.redirect.statusCode
} else {
  console.log(page.name) // "Consulting"
}

getBySlug

TypeScript
getBySlug(slug: string, options?: BaseRequestOptions): Promise<Page>

Fetches one published page by slug, with its resolved data, SEO settings and alternates. Without a locale, the page is looked up in the site's default locale. With one, a missing translation is served from the fallback locale and flagged isFallback: pass fallback: false to get a 404 instead. With cache: true, cached for 5 minutes. Throws LynkowError NOT_FOUND for an unknown or unpublished slug, and for an empty, '.' or '..' slug, which is refused without a request.

Parameter

Type

Description

slug

string

The page slug, such as 'about'.

options

BaseRequestOptions

Request options. locale selects the translation, fallback: false refuses a fallback.

Returns: Promise<Page>

TypeScript
const page = await lynkow.pages.getBySlug('about')
console.log(page.data)        // Resolved DataSource content
console.log(page.seo)         // SEO metadata
console.log(page.alternates)  // Other locale versions

getJsonLd

TypeScript
getJsonLd(slug: string, options?: BaseRequestOptions): Promise<object[]>

Fetches the Schema.org JSON-LD graph of a page, to embed in a <script type="application/ld+json"> tag. Resolves to an array of nodes, never a single object. The page is chosen as in getBySlug(). With cache: true, cached for 5 minutes. Throws LynkowError NOT_FOUND for an unknown slug, and for an empty, '.' or '..' slug, which is refused without a request.

Parameter

Type

Description

slug

string

The page slug, such as 'about'.

options

BaseRequestOptions

Request options. locale selects the translation, fallback: false refuses a fallback.

Returns: Promise<object[]>

TypeScript
const graph = await lynkow.pages.getJsonLd('about')
const webPage = graph.find(
  (node) => (node as { '@type'?: unknown })['@type'] === 'WebPage'
)
// Embed the graph in your HTML <head> through a serializer that escapes
// `<`, as renderJsonLdGraph(graph) does, never a raw JSON.stringify()
// inside a <script>: a `<!--` or `</script>` in a value would reach the
// HTML parser.

list

TypeScript
list(options?: PagesListOptions): Promise<PagesListResponse>

Fetches the published pages as summaries, without their resolved data, optionally filtered by tag. Without a locale, only default-locale pages are listed. With one, each translation group appears once and a missing translation is served from the fallback locale (fallback: false drops those). Link to publicPath, not path. With cache: true, cached for 5 minutes.

Parameter

Type

Description

options

PagesListOptions

tag to filter, plus request options (locale, fallback).

Returns: Promise<PagesListResponse>

TypeScript
// List all pages
const { data } = await lynkow.pages.list()

// List only legal documents
const { data } = await lynkow.pages.list({ tag: 'legal' })