Service for URL path resolution and static site generation (SSG).
Accessible via lynkow.paths. Provides methods to list all available paths
for static generation, resolve a URL path to its content or category, and
check for configured redirects. Cached for 5 minutes (SHORT TTL).
Access via: lynkow.paths
Methods
4 methods
clearCache
clearCache(): voidInvalidates all cached path responses (list and resolve lookups). Call this after knowing the site's URL structure has changed (e.g. new content published, slugs updated) to force fresh data.
Returns: void
list
list(options?: BaseRequestOptions): Promise<PathsListResponse>Retrieves all available URL paths for the site, intended for static site generation (SSG). Returns every published content and category path with segments, type, locale, and last modification date. Cached for 5 minutes per locale.
Parameter | Type | Description |
|---|---|---|
|
| Request options; use |
Returns: Promise<PathsListResponse>
// In Next.js generateStaticParams()
export async function generateStaticParams() {
const { paths } = await lynkow.paths.list()
return paths.map(p => ({
slug: p.segments
}))
}matchRedirect
matchRedirect(path: string, options?: BaseRequestOptions): Promise<Redirect | null>Checks if a URL path has a configured server-side redirect. Returns the
redirect rule if one matches, or null if no redirect is configured.
This method is NOT cached to ensure redirect changes take effect immediately.
A 404 response from the API is treated as "no redirect found" (returns null).
Parameter | Type | Description |
|---|---|---|
|
| The URL path to check for redirects (e.g. |
|
| Request options (custom fetch options) |
Returns: Promise<Redirect | null>
// In a Next.js middleware
const redirect = await lynkow.paths.matchRedirect(pathname)
if (redirect) {
return NextResponse.redirect(redirect.target, redirect.statusCode)
}
// No redirect, continue to normal page renderingresolve
resolve(path: string, options?: BaseRequestOptions): Promise<ResolveResponse>Resolves a URL path to its corresponding content article or category.
Returns a discriminated union: check the type field to determine whether
the path matched a content ('content') or a category ('category').
Cached for 5 minutes per path+locale.
Parameter | Type | Description |
|---|---|---|
|
| The URL path to resolve (e.g. |
|
| Request options; use |
Returns: Promise<ResolveResponse>
const result = await lynkow.paths.resolve('/blog/tech/my-article')
if (result.type === 'content') {
// Render the full article
console.log(result.content.title)
} else if (result.type === 'category') {
// Render the category listing page
console.log(result.category.name)
console.log(result.contents.data.length) // Articles in this category
}