Глобальный рефакторинг компонетов

This commit is contained in:
Web-serfer 2026-04-15 21:32:55 +05:00
parent ba9806a85a
commit 27804e9345
9 changed files with 89 additions and 33 deletions

View file

@ -1,4 +1,5 @@
import PocketBase from 'pocketbase';
import type { Post } from '../globalInterfaces';
const PB_URL = import.meta.env.POCKETBASE_URL || 'http://127.0.0.1:8090';
@ -6,21 +7,6 @@ export const pb = new PocketBase(PB_URL);
pb.collection('_superusers').authRefresh().catch(() => {});
export interface Post {
id: string;
slug: string;
title: string;
description: string;
author: string;
category: string;
categoryColor: string;
date: string;
readTime: string;
image: string;
content?: string;
draft: boolean;
}
export async function getPosts(options?: {
page?: number;
perPage?: number;
@ -71,11 +57,11 @@ export async function getAllCategories(): Promise<string[]> {
fields: 'category',
});
const categories = (result || []).map((post: any) => post.category).filter(Boolean);
const categories = (result || []).map((post) => post.category as string).filter(Boolean);
return ['Все', ...new Set(categories)];
}
export function getPostImageUrl(post: any): string {
export function getPostImageUrl(post: { image?: string }): string {
if (post.image) {
const fileUrl = pb.files.getUrl(post, post.image);
if (fileUrl.startsWith('/')) {