Skip to content

Commit 8e602d1

Browse files
committed
feat(blog): 优化团队博客列表支持多语言博客
1 parent 8a470a2 commit 8e602d1

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

src/components/forum/blog/ForumBlogPage.vue

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,37 @@
11
<script setup lang="ts">
2+
import { computed } from 'vue'
23
import posts from '~/_data/posts.json'
3-
import { useData } from 'vitepress'
44
import { useLocalized } from '@/hooks/useLocalized'
55
import ForumDate from '../ForumDate.vue'
66
import { VPLink } from 'vitepress/theme'
77
import { extractPlainText } from '../utils'
8+
import { getForumLocaleLabelGetter } from '~/composables/getForumLocaleGetter'
9+
import { useData } from 'vitepress'
10+
11+
const localeLabelGetter = getForumLocaleLabelGetter()
812
913
const { message } = useLocalized()
14+
const { lang } = useData()
15+
16+
const filteredPosts = computed(() =>
17+
posts.filter(
18+
(post) =>
19+
post.tags &&
20+
post.tags.some(
21+
(label) =>
22+
label ===
23+
localeLabelGetter.getLabel(lang.value.substring(0, 2).toUpperCase()),
24+
),
25+
),
26+
)
1027
</script>
1128

1229
<template>
1330
<div class="divide-y">
1431
<ul class="c-[var(--vp-c-text-1)]">
1532
<li
1633
class="py-12 border-b border-b-[var(--vp-c-divider)]"
17-
v-for="{ title, createdAt, contentRaw, id } of posts"
34+
v-for="{ title, createdAt, contentRaw, id } of filteredPosts"
1835
>
1936
<article
2037
class="space-y-2 xl:grid xl:grid-cols-4 xl:space-y-0 xl:items-baseline"

src/components/forum/topic/ForumTopicFooter.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
<script setup lang="ts">
1212
import ForumShareThis from '../ForumShareThis.vue'
13-
import { useData } from 'vitepress'
1413
1514
defineProps<{
1615
prevPageLink: string

src/en/blog/index.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,4 @@ aside: false
66
wip: true
77
---
88

9-
<script setup lang="ts">
10-
import ForumBlogPage from '~/components/forum/blog/ForumBlogPage.vue'
11-
</script>
12-
13-
<ForumBlogPage />
9+
<!--@include: @/zh/blog/index.md-->

src/ja/blog/index.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,4 @@ aside: false
66
wip: true
77
---
88

9-
<script setup lang="ts">
10-
import ForumBlogPage from '~/components/forum/blog/ForumBlogPage.vue'
11-
</script>
12-
13-
<ForumBlogPage />
9+
<!--@include: @/zh/blog/index.md-->

0 commit comments

Comments
 (0)