feat: add featured posts grid and update blog terminology
- Introduced a new FeaturedPostsGrid component to display featured posts on the homepage. - Updated the Home component to fetch and render featured posts from the WordPress API. - Changed instances of "بلاگ" to "دانشنامه" across various components for consistent terminology.
This commit is contained in:
+6
-1
@@ -71,6 +71,9 @@ export interface GetPostsOptions {
|
||||
perPage?: number;
|
||||
search?: string;
|
||||
categoryId?: number;
|
||||
/** ترتیب بر اساس: date, modified, title, ... در وردپرس. برای اولویت دستی (menu_order) پلاگین/فیلتر در وردپرس لازم است. */
|
||||
orderby?: string;
|
||||
order?: "asc" | "desc";
|
||||
}
|
||||
|
||||
async function fetchWithTimeout(
|
||||
@@ -96,12 +99,14 @@ async function fetchWithTimeout(
|
||||
export async function getPosts(
|
||||
options: GetPostsOptions = {}
|
||||
): Promise<GetPostsResult> {
|
||||
const { page = 1, perPage = 9, search, categoryId } = options;
|
||||
const { page = 1, perPage = 9, search, categoryId, orderby, order } = options;
|
||||
const params = new URLSearchParams();
|
||||
params.set("page", String(page));
|
||||
params.set("per_page", String(perPage));
|
||||
if (search?.trim()) params.set("search", search.trim());
|
||||
if (categoryId) params.set("categories", String(categoryId));
|
||||
if (orderby) params.set("orderby", orderby);
|
||||
if (order) params.set("order", order);
|
||||
params.set("_embed", "1");
|
||||
|
||||
const url = `${WP_API_BASE}/posts?${params.toString()}`;
|
||||
|
||||
Reference in New Issue
Block a user