minhnt-dev: get by slug
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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
@@ -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
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user