Новые изменения в компоенты
This commit is contained in:
parent
a14c18542e
commit
faf02848ed
3 changed files with 33 additions and 19 deletions
|
|
@ -147,14 +147,17 @@ export async function getPostBySlug(slug: string): Promise<Post | null> {
|
|||
return result.items[0] as unknown as Post;
|
||||
}
|
||||
|
||||
export async function getAllCategories(): Promise<string[]> {
|
||||
const result = await pb.collection('posts').getFullList({
|
||||
filter: 'draft = false',
|
||||
fields: 'category',
|
||||
});
|
||||
export const FIXED_BLOG_CATEGORIES = [
|
||||
'ДТП',
|
||||
'Лишение прав',
|
||||
'Страховые споры',
|
||||
'Штрафы ГИБДД',
|
||||
'Возмещение ущерба',
|
||||
'Судебные дела',
|
||||
];
|
||||
|
||||
const categories = (result || []).map((post) => post.category as string).filter(Boolean);
|
||||
return ['Все', ...new Set(categories)];
|
||||
export async function getAllCategories(): Promise<string[]> {
|
||||
return ['Все', ...FIXED_BLOG_CATEGORIES];
|
||||
}
|
||||
|
||||
export function getPostImageUrl(post: { image?: string }): string {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue