DocumentationAmertaThemeUtilitiesBlogFunctions

Get Related Posts

amerta


amerta / amerta/theme/utilities/blog / getRelatedPosts

Function: getRelatedPosts()

getRelatedPosts(postId, limit?, locale?): Promise<Post[]>

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

Retrieves related posts for a given post based on shared categories, with shuffled results.

Parameters

| Parameter | Type | Default value | Description | | ------ | ------ | ------ | ------ | | postId | string | undefined | The ID of the current post. | | limit | number | 4 | Maximum number of related posts to return. | | locale? | string | undefined | Optional locale code for localization. |

Returns

Promise<Post[]>

Array of related posts.

Example

const related = await getRelatedPosts("post123", 4, "en");