Service for retrieving published blog articles (contents).
Accessible via lynkow.contents. All methods return only published content
visible to the public API. Responses are cached in-memory for 5 minutes
(SHORT TTL) when a cache adapter is configured on the client.
Access via: lynkow.contents
Methods
3 methods
clearCache
clearCache(): voidInvalidate every cached response produced by this service (list
queries, slug lookups, single-content fetches). Call after an admin
mutation or on receipt of a content.* webhook so the next public
request bypasses the 5-minute SWR cache and hits the origin.
Returns: void
// In a Next.js route handler receiving a Lynkow webhook:
if (event.type === 'content.updated') {
lynkow.contents.clearCache()
}getBySlug
getBySlug(slug: string, options?: BaseRequestOptions): Promise<Content>Retrieves a single published article by its URL-friendly slug. Returns the full content including body (HTML), SEO metadata, author, categories, tags, and structured data (JSON-LD). Cached for 5 minutes per slug+locale combination.
Parameter | Type | Description |
|---|---|---|
|
| The unique URL slug of the content (e.g. |
|
| Request options; use |
Returns: Promise<Content>
const content = await lynkow.contents.getBySlug('my-article')
console.log(content.title) // Article title
console.log(content.body) // HTML body string
console.log(content.author?.fullName) // Author name
console.log(content.categories) // Associated categorieslist
list(filters?: ContentsFilters, options?: BaseRequestOptions): Promise<ContentsListResponse>Retrieves a paginated list of published blog articles, sorted by publication date (newest first by default). Results are cached for 5 minutes per unique filter combination.
Parameter | Type | Description |
|---|---|---|
|
| Optional filters to narrow down results:<br> - |
|
| Base request options (locale override, custom fetch options) |
Returns: Promise<ContentsListResponse>
// Fetch the first page of articles in the "tech" category
const { data, meta } = await lynkow.contents.list({
page: 1,
limit: 10,
category: 'tech'
})
// Search for articles
const results = await lynkow.contents.list({ search: 'typescript' })