← @mortar-kit/core

resolveUrlfunction

import { resolveUrl } from '@mortar-kit/core'

function resolveUrl(collections: readonly AnyCollection[], url: string | URL): { collection: string; slug: string } | undefined

The document a path of the site shows, by the collections' url patterns: /posts/hello → { collection: 'posts', slug: 'hello' }. As in routers, the more specific pattern wins (/posts/:slug over /:slug), and paths compare case-insensitively. Undefined when no pattern matches.

Parameters

collections: readonly AnyCollection[]
url: string | URL

Returns

{ collection: string; slug: string } | undefined