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

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 nodemailer from 'nodemailer';
import type { EmailOptions } from '../globalInterfaces';
const SMTP_HOST = import.meta.env.SMTP_HOST || 'localhost';
const SMTP_PORT = import.meta.env.SMTP_PORT || 1025;
@ -20,12 +21,6 @@ function getTransporter() {
return transporter;
}
export interface EmailOptions {
to: string;
subject: string;
html: string;
}
export async function sendEmail(options: EmailOptions): Promise<boolean> {
try {
console.log('Sending email to:', options.to);

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('/')) {