Service for retrieving published pages (Site Blocks of type "page").

Accessible via lynkow.pages. Pages are CMS-managed, schema-driven content blocks (e.g. "About", "Contact", legal pages). Unlike blog articles, pages use DataSource-resolved data instead of a rich text body. Responses are cached for 5 minutes (SHORT TTL) when a cache adapter is configured.

Access via: lynkow.pages

Methods

5 methods

clearCache

TypeScript
clearCache(): void

Invalidates all cached page responses (lists, slug lookups, path lookups, and JSON-LD data). Call this after knowing pages have been updated to force fresh data on the next request.

Returns: void


getByPath

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

Retrieves a page by its full URL path, which may include nested segments (e.g. /services/consulting). Useful when you have the path from a URL but not the slug. Returns the same full page data as getBySlug(). Cached for 5 minutes per path+locale.

Parameter

Type

Description

path

string

The full URL path of the page (e.g. '/services/consulting', '/about').<br> Must start with a forward slash.

options

BaseRequestOptions

Request options; use locale to fetch a specific localized version

Returns: Promise<Page>

TypeScript
// Resolve a page from the current URL
const page = await lynkow.pages.getByPath('/services/consulting')
console.log(page.name) // "Consulting"

getBySlug

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

Retrieves a single page by its slug, including fully resolved DataSource data, SEO settings, and alternate locale versions. Cached for 5 minutes per slug+locale.

Parameter

Type

Description

slug

string

The unique URL slug of the page (e.g. 'about', 'contact', 'privacy-policy')

options

BaseRequestOptions

Request options; use locale to fetch a specific localized version

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<Record<string, unknown>>

Retrieves Schema.org JSON-LD structured data for a page, ready to be embedded in a <script type="application/ld+json"> tag for search engine optimization. Cached for 5 minutes per slug+locale.

Parameter

Type

Description

slug

string

The page slug to generate JSON-LD for (e.g. 'about', 'contact')

options

BaseRequestOptions

Request options; use locale to get locale-specific structured data

Returns: Promise<Record<string, unknown>>

TypeScript
const jsonLd = await lynkow.pages.getJsonLd('about')
// Embed in your HTML <head>
// <script type="application/ld+json">{JSON.stringify(jsonLd)}</script>

list

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

Retrieves a list of all published pages on the site. Optionally filter by tag to get a subset (e.g. legal documents). Returns page summaries without resolved data. Cached for 5 minutes per locale+tag.

Parameter

Type

Description

options

PagesListOptions

Request options:<br> - tag — filter pages by tag slug (e.g. 'legal' for privacy policy, terms, etc.)<br> - locale — override the client's default locale

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' })