basic structure setup

This commit is contained in:
dimitar committed 2026-01-10 19:41:04 +01:00
commit 71dfd86187
89 files changed
+41490

No files matched your search

+88
View File
@@ -0,0 +1,88 @@
const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:3000/api/v1';
export interface Article {
id: string;
title: string;
content: string;
excerpt: string | null;
slug: string;
featuredImage: string;
tags: string[];
status: 'draft' | 'published' | 'archived';
views: number;
strapiId: string | null;
authorId: string | null;
categoryId: string | null;
author?: {
id: string;
name: string;
slug: string;
bio: string | null;
avatar: string | null;
};
category?: {
id: string;
name: string;
slug: string;
description: string | null;
};
createdAt: string;
updatedAt: string;
}
export interface ArticlesResponse {
data: Article[];
total: number;
page?: number;
limit?: number;
}
export interface FindArticlesParams {
category?: string;
author?: string;
tag?: string;
status?: 'draft' | 'published' | 'archived';
search?: string;
page?: number;
limit?: number;
}
export async function fetchArticles(params: FindArticlesParams = {}): Promise<ArticlesResponse> {
console.log('fetchArticles called with params:', params, 'API_BASE_URL:', API_BASE_URL);
const searchParams = new URLSearchParams();
Object.entries(params).forEach(([key, value]) => {
if (value !== undefined) {
searchParams.append(key, String(value));
}
});
const url = `${API_BASE_URL}/articles?${searchParams}`;
console.log('Fetching from:', url);
const response = await fetch(url);
console.log('Response status:', response.status, 'ok:', response.ok);
if (!response.ok) {
throw new Error('Failed to fetch articles');
}
const data = await response.json();
console.log('Response data:', data);
return data;
}
export async function fetchArticleBySlug(slug: string): Promise<Article> {
const response = await fetch(`${API_BASE_URL}/articles/slug/${slug}`);
if (!response.ok) {
throw new Error('Failed to fetch article');
}
return response.json();
}
export async function fetchArticleById(id: string): Promise<Article> {
const response = await fetch(`${API_BASE_URL}/articles/${id}`);
if (!response.ok) {
throw new Error('Failed to fetch article');
}
return response.json();
}
+6
View File
@@ -0,0 +1,6 @@
import { clsx, type ClassValue } from 'clsx'
import { twMerge } from 'tailwind-merge'
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}