diff --git a/components/NewsArticleCreate.vue b/components/NewsArticleCreate.vue index 7759062..f5d0b93 100644 --- a/components/NewsArticleCreate.vue +++ b/components/NewsArticleCreate.vue @@ -37,10 +37,10 @@
- + { // Reset form newArticle.value = { title: '', - excerpt: '', + description: '', content: '', image: '', tags: [] diff --git a/components/NewsDirectory.vue b/components/NewsDirectory.vue index 2bff2ad..d4e0572 100644 --- a/components/NewsDirectory.vue +++ b/components/NewsDirectory.vue @@ -87,7 +87,7 @@

{{ article.title }}

-

+

@@ -115,7 +115,7 @@ const availableTags = computed(() => { if (!articles.value) return []; const tags = new Set(); articles.value.forEach(article => { - article.tags.forEach(tag => tags.add(tag)); + article.tags.forEach(tag => tags.add(tag.name)); }); return Array.from(tags); }); @@ -151,7 +151,7 @@ const filteredArticles = computed(() => { return articles.value.filter((article) => { const matchesSearch = article.title.toLowerCase().includes(searchQuery.value.toLowerCase()) || - article.excerpt.toLowerCase().includes(searchQuery.value.toLowerCase()); + article.description.toLowerCase().includes(searchQuery.value.toLowerCase()); const articleDate = new Date(article.publishedAt); const now = new Date(); @@ -175,7 +175,7 @@ const filteredArticles = computed(() => { } const matchesTags = selectedTags.value.length === 0 || - selectedTags.value.every(tag => article.tags.includes(tag)); + selectedTags.value.every(tag => article.tags.find((e) => e.name == tag)); return matchesSearch && matchesDate && matchesTags; }); diff --git a/composables/useNews.ts b/composables/news.ts similarity index 89% rename from composables/useNews.ts rename to composables/news.ts index f5f2093..993d44c 100644 --- a/composables/useNews.ts +++ b/composables/news.ts @@ -23,20 +23,20 @@ export const useNews = () => { const create = async (article: { title: string; - excerpt: string; + description: string; content: string; image?: string; tags: string[]; authorId: string; }) => { - return await $fetch('/api/v1/news', { + return await $fetch('/api/v1/admin/news', { method: 'POST', body: article }); }; const remove = async (id: string) => { - return await $fetch(`/api/v1/news/${id}`, { + return await $fetch(`/api/v1/admin/news/${id}`, { method: 'DELETE' }); }; diff --git a/pages/news/article/[id]/index.vue b/pages/news/[id]/index.vue similarity index 91% rename from pages/news/article/[id]/index.vue rename to pages/news/[id]/index.vue index 112beb1..8b6169f 100644 --- a/pages/news/article/[id]/index.vue +++ b/pages/news/[id]/index.vue @@ -1,5 +1,5 @@