(filterParams?: {
author?: string;
tag?: string;
category?: string;
search?: string;
})
| 192 | } |
| 193 | |
| 194 | export async function getAllPosts(filterParams?: { |
| 195 | author?: string; |
| 196 | tag?: string; |
| 197 | category?: string; |
| 198 | search?: string; |
| 199 | }): Promise<Post[]> { |
| 200 | const query: Record<string, any> = { |
| 201 | _embed: true, |
| 202 | per_page: 100, |
| 203 | }; |
| 204 | |
| 205 | if (filterParams?.search) query.search = filterParams.search; |
| 206 | if (filterParams?.author) query.author = filterParams.author; |
| 207 | if (filterParams?.tag) query.tags = filterParams.tag; |
| 208 | if (filterParams?.category) query.categories = filterParams.category; |
| 209 | |
| 210 | return wordpressFetchGraceful<Post[]>("/wp-json/wp/v2/posts", [], query, [ |
| 211 | "wordpress", |
| 212 | "posts", |
| 213 | ]); |
| 214 | } |
| 215 | |
| 216 | export async function getPostById(id: number): Promise<Post> { |
| 217 | return wordpressFetch<Post>(`/wp-json/wp/v2/posts/${id}`); |
no test coverage detected