DocumentationAmertaThemeUtilitiesBlogFunctions

Get Category By Slug

amerta


amerta / amerta/theme/utilities/blog / getCategoryBySlug

Function: getCategoryBySlug()

getCategoryBySlug(slug, locale?): Promise<Category | null>

Defined in: amerta/theme/utilities/blog.ts:83

Retrieves a category by its slug.

Parameters

| Parameter | Type | Description | | ------ | ------ | ------ | | slug | string | The slug of the category. | | locale? | string | Optional locale code for localization. |

Returns

Promise<Category | null>

The category or null if not found.

Example

const category = await getCategoryBySlug("tech", "en");