Новые изменения в коде проекта

This commit is contained in:
Web-serfer 2026-04-15 12:36:58 +05:00
parent 0777fc201f
commit aef12e853d
12 changed files with 159 additions and 15 deletions

View file

@ -4,6 +4,8 @@ const PB_URL = import.meta.env.POCKETBASE_URL || 'http://127.0.0.1:8090';
export const pb = new PocketBase(PB_URL);
pb.collection('_superusers').authRefresh().catch(() => {});
export interface Post {
id: string;
slug: string;
@ -14,7 +16,7 @@ export interface Post {
categoryColor: string;
date: string;
readTime: string;
imageUrl: string;
image: string;
content?: string;
draft: boolean;
}
@ -71,4 +73,15 @@ export async function getAllCategories(): Promise<string[]> {
const categories = (result || []).map((post: any) => post.category).filter(Boolean);
return ['Все', ...new Set(categories)];
}
export function getPostImageUrl(post: any): string {
if (post.image) {
const fileUrl = pb.files.getUrl(post, post.image);
if (fileUrl.startsWith('/')) {
return `${PB_URL}${fileUrl}`;
}
return fileUrl;
}
return '/images/blog/default.avif';
}