minhnt-dev: get by slug

This commit is contained in:
MoreStrive
2024-05-31 15:04:22 +07:00
parent 7b01ce6170
commit 892bddde2f
3 changed files with 4 additions and 4 deletions
@@ -55,7 +55,7 @@ const drop = (e: any) => {
<div class="basic-article_content" :class="[!parseData && 'no-data']">
<div>
<template v-if="parseData">
<nuxt-link :to="`/bai-viet/${parseData.id}`">
<nuxt-link :to="`/bai-viet/${parseData.slug}`">
<h3 v-if="!LAYOUT_PARSE['HIDE'] || !LAYOUT_PARSE['HIDE'].includes('title')" class="mb-1 line-clamp-2 text-base font-700 hover:text-primary-100 transition-all duration-300">
{{ parseData.title?.replace(/<[^>]+>/g, '') }}
</h3>
+1 -1
View File
@@ -23,7 +23,7 @@ const store = reactive({
(async () => {
try {
store.article.getArticleById(route.params.slug);
store.article.getArticleBySlug(route.params.slug);
} catch (error) {
console.error("Error fetching data:", error);
}
+2 -2
View File
@@ -10,7 +10,7 @@ export const useArticleStore = defineStore("article", () => {
} catch (error: any) {}
}
const getArticleByCode = async (slug: string) => {
const getArticleBySlug = async (slug: string) => {
try {
const { data} = await useFetch(`/api/articles/get-by-slug/${slug}`)
currentArticle.value = {}
@@ -21,7 +21,7 @@ export const useArticleStore = defineStore("article", () => {
return {
currentArticle,
getArticleById,
getArticleByCode
getArticleBySlug
}
});