55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import { get } from './client';
|
|
|
|
export type BlogPostStatus = 'draft' | 'scheduled' | 'published' | 'archived';
|
|
export type BlogPostCategory = 'industry' | 'technology' | 'guides' | 'news';
|
|
|
|
export interface BlogPost {
|
|
id: string;
|
|
title: string;
|
|
slug: string;
|
|
excerpt: string;
|
|
content: string;
|
|
coverImageUrl?: string;
|
|
category: BlogPostCategory;
|
|
tags: string[];
|
|
authorName: string;
|
|
status: BlogPostStatus;
|
|
isFeatured: boolean;
|
|
publishedAt?: string;
|
|
metaTitle?: string;
|
|
metaDescription?: string;
|
|
primaryKeyword?: string;
|
|
secondaryKeywords: string[];
|
|
createdAt: string;
|
|
updatedAt: string;
|
|
}
|
|
|
|
export interface BlogPostListResponse {
|
|
posts: BlogPost[];
|
|
total: number;
|
|
limit: number;
|
|
offset: number;
|
|
}
|
|
|
|
export interface BlogPostFilters {
|
|
category?: BlogPostCategory;
|
|
search?: string;
|
|
limit?: number;
|
|
offset?: number;
|
|
}
|
|
|
|
export async function getBlogPosts(filters: BlogPostFilters = {}): Promise<BlogPostListResponse> {
|
|
const params = new URLSearchParams();
|
|
if (filters.category) params.set('category', filters.category);
|
|
if (filters.search) params.set('search', filters.search);
|
|
if (filters.limit) params.set('limit', String(filters.limit));
|
|
if (filters.offset) params.set('offset', String(filters.offset));
|
|
|
|
const query = params.toString();
|
|
return get<BlogPostListResponse>(`/api/v1/blog${query ? `?${query}` : ''}`);
|
|
}
|
|
|
|
export async function getBlogPost(slug: string): Promise<BlogPost> {
|
|
return get<BlogPost>(`/api/v1/blog/${slug}`);
|
|
}
|