mirror of
https://github.com/Drop-OSS/drop.git
synced 2026-06-22 04:11:32 +10:00
feat: file uploads on news articles
This commit is contained in:
+10
-25
@@ -2,17 +2,17 @@ export const useNews = () => {
|
||||
const getAll = async (options?: {
|
||||
limit?: number;
|
||||
skip?: number;
|
||||
orderBy?: 'asc' | 'desc';
|
||||
orderBy?: "asc" | "desc";
|
||||
tags?: string[];
|
||||
search?: string;
|
||||
}) => {
|
||||
const query = new URLSearchParams();
|
||||
|
||||
if (options?.limit) query.set('limit', options.limit.toString());
|
||||
if (options?.skip) query.set('skip', options.skip.toString());
|
||||
if (options?.orderBy) query.set('order', options.orderBy);
|
||||
if (options?.tags?.length) query.set('tags', options.tags.join(','));
|
||||
if (options?.search) query.set('search', options.search);
|
||||
|
||||
if (options?.limit) query.set("limit", options.limit.toString());
|
||||
if (options?.skip) query.set("skip", options.skip.toString());
|
||||
if (options?.orderBy) query.set("order", options.orderBy);
|
||||
if (options?.tags?.length) query.set("tags", options.tags.join(","));
|
||||
if (options?.search) query.set("search", options.search);
|
||||
|
||||
return await useFetch(`/api/v1/news?${query.toString()}`);
|
||||
};
|
||||
@@ -21,30 +21,15 @@ export const useNews = () => {
|
||||
return await useFetch(`/api/v1/news/${id}`);
|
||||
};
|
||||
|
||||
const create = async (article: {
|
||||
title: string;
|
||||
description: string;
|
||||
content: string;
|
||||
image?: string;
|
||||
tags: string[];
|
||||
authorId: string;
|
||||
}) => {
|
||||
return await $fetch('/api/v1/admin/news', {
|
||||
method: 'POST',
|
||||
body: article
|
||||
});
|
||||
};
|
||||
|
||||
const remove = async (id: string) => {
|
||||
return await $fetch(`/api/v1/admin/news/${id}`, {
|
||||
method: 'DELETE'
|
||||
method: "DELETE",
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
getAll,
|
||||
getById,
|
||||
create,
|
||||
remove
|
||||
remove,
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user