import { CalendarOutlined, CommentOutlined, EyeOutlined, ReadOutlined, TagsOutlined } from '@antdv-next/icons'; import { computed, defineComponent, onBeforeUnmount, ref, Transition } from 'vue'; import { RouterLink, useRoute } from 'vue-router'; import BlogLayout from '@/components/blog/BlogLayout'; import BlogShare from '@/components/blog/BlogShare'; import { BlogButton, BlogForm, BlogInput, BlogTextArea, } from '@/components/blog/antdvComponents'; import { articles, getArticleBySlug, getRelatedArticles, getTagSlugByLabel } from '@/data/blog'; import { clearBlogPostRefs, setBlogPostArticleRef, setBlogPostCommentInputRef, setBlogPostCommentRef, } from '@/hooks/useBlogDomRefs'; export default defineComponent({ name: 'BlogPostPage', setup() { const route = useRoute(); const article = computed(() => getArticleBySlug(String(route.params.slug)) ?? articles[0]); const articleIndex = computed(() => articles.findIndex((item) => item.slug === article.value?.slug)); const previousArticle = computed(() => { const index = articleIndex.value; return articles[index > 0 ? index - 1 : articles.length - 1] ?? article.value; }); const nextArticle = computed(() => { const index = articleIndex.value; return articles[index >= 0 && index < articles.length - 1 ? index + 1 : 0] ?? article.value; }); const relatedArticles = computed(() => (article.value ? getRelatedArticles(article.value) : [])); const commentContent = ref(''); const commentEmail = ref(''); const commentName = ref(''); onBeforeUnmount(() => { clearBlogPostRefs(); }); return () => { const currentArticle = article.value; if (!currentArticle) { return (
没有找到文章。
); } const currentPreviousArticle = previousArticle.value ?? currentArticle; const currentNextArticle = nextArticle.value ?? currentArticle; return (
setBlogPostArticleRef(target as HTMLElement | null)} class="kt-blog__post kt-blog__post--full kt-blog__card" >
{currentArticle.title}
{currentArticle.content.map((paragraph) => (

{paragraph}

))}
上一篇 {currentPreviousArticle.title}
下一篇 {currentNextArticle.title}

评论

暂无评论
setBlogPostCommentRef(target as HTMLElement | null)} class="kt-blog__comment-form kt-blog__card" >

发送评论

setBlogPostCommentInputRef(target)} class="kt-blog__comment-form-content kt-blog__input" placeholder="评论内容" name="comment" v-model:value={commentContent.value} />
昵称
邮箱
发送评论
); }; }, });