Reads global blocks, the reusable pieces shared by every page such as a header, footer or
navigation. Available as lynkow.globals and lynkow.blocks. With cache: true, a single
block is cached for 10 minutes. The site configuration is never cached.
Access via: lynkow.globals
Methods
4 methods
clearCache
clearCache(): voidClears every cached global block held by the client. Call it when a globalBlock.updated webhook
arrives so the next read fetches fresh data.
Returns: void
lynkow.globals.clearCache()getBySlug
getBySlug(slug: string, options?: BaseRequestOptions): Promise<GlobalBlockResponse>Fetches one published global block by slug, with its resolved data. Use siteConfig() instead to
load every block at once. Without a locale, the default-locale block is returned. With one, a missing
translation is served from the fallback locale and fallback: false turns that into a 404.
With cache: true, cached for 10 minutes. Throws LynkowError NOT_FOUND for an unknown slug,
and for an empty, '.' or '..' slug, which is refused without a request.
Parameter | Type | Description |
|---|---|---|
|
| The block slug, such as |
|
| Request options. |
Returns: Promise<GlobalBlockResponse>
const { data } = await lynkow.globals.getBySlug('header')
console.log(data.name) // "Header"
console.log(data.data) // Resolved content (links, logo, menu items, etc.)global
global(slug: string, options?: BaseRequestOptions): Promise<GlobalBlockResponse>Fetches one global block by slug, exactly as getBySlug() does.
Parameter | Type | Description |
|---|---|---|
|
| The block slug. |
|
| Request options. |
Returns: Promise<GlobalBlockResponse>
const { data } = await lynkow.globals.getBySlug('footer')siteConfig
siteConfig(options?: BaseRequestOptions): Promise<SiteConfigResponse>Fetches the site info and every published global block in one request, keyed by slug, for your
layout (header, footer, navigation). Without a locale, default-locale blocks are returned. With one,
each block missing a translation is served from the fallback locale (fallback: false drops those).
Not cached, so a branding change shows on the next call. A site with no global blocks returns an empty globals.
Throws LynkowError NOT_FOUND for an unknown site, FORBIDDEN for an inactive site
or a request origin that does not match the site's domain, and PAYMENT_REQUIRED when the
subscription no longer covers public delivery.
Parameter | Type | Description |
|---|---|---|
|
| Request options. |
Returns: Promise<SiteConfigResponse>
const { data } = await lynkow.globals.siteConfig()
console.log(data.site.name) // "My Site"
const header = data.globals['header'] // Resolved header block data
const footer = data.globals['footer'] // Resolved footer block data