Post tag & category filtered page

This commit is contained in:
LittleSheep 2024-08-17 00:51:09 +08:00
parent 2b9601640b
commit 58ad9996cd
7 changed files with 108 additions and 6 deletions

View File

@ -27,7 +27,10 @@
</article>
<v-card v-if="post.body?.attachments?.length > 0" class="mb-5">
<attachment-carousel :no-clickable-attachment="props.noClickableAttachment" :attachments="post.body?.attachments" />
<attachment-carousel
:no-clickable-attachment="props.noClickableAttachment"
:attachments="post.body?.attachments"
/>
</v-card>
<div class="text-sm flex flex-col">
@ -45,8 +48,18 @@
</span>
</div>
<div v-if="post.tags?.length > 0" class="text-xs text-grey flex flex-row gap-1 mt-3">
<span v-for="tag in post.tags">#{{ tag.alias }}</span>
<div
v-if="post.tags?.length > 0"
class="text-xs text-grey flex flex-row gap-1 mt-3"
>
<nuxt-link
v-for="tag in post.tags"
:to="`/posts/tags/${tag.alias}`"
class="hover:underline hover:underline-dotted"
@click.stop
>
#{{ tag.alias }}
</nuxt-link>
</div>
</v-card-text>
</v-card>

View File

@ -7,7 +7,7 @@
</template>
<script setup lang="ts">
const props = defineProps<{ author?: string, realmId?: number }>()
const props = defineProps<{ author?: string, tag?: string, category?: string, realmId?: number }>()
const config = useRuntimeConfig()
@ -26,6 +26,13 @@ async function loadPost({ done }: any) {
searchQueries.set("realmId", props.realmId.toString())
}
if (props.tag) {
searchQueries.set("tag", props.tag)
}
if (props.category) {
searchQueries.set("category", props.category)
}
const res = await fetch(`${config.public.solarNetworkApi}/cgi/interactive/posts?` + searchQueries)
const result = await res.json()

View File

@ -8,6 +8,8 @@
"navGalleryCaption": "Explore files that uploaded by Solar Network users.",
"navPosts": "Posts",
"navPostsCaption": "Explore posts that posted by Solar Network users.",
"navPostsCaptionWithTag": "Explore posts with tag {0}.",
"navPostsCaptionWithCategory": "Explore posts in category {0}.",
"indexIntroduce": "An energetic software company that create wonderful software which everyone love.",
"indexProductListHint": "See some of our products just there",
"indexActivities": "Activities",

View File

@ -8,6 +8,8 @@
"navGalleryCaption": "探索整个 Solar Network 上的文件。",
"navPosts": "帖子",
"navPostsCaption": "探索整个 Solar Network 上的帖子。",
"navPostsCaptionWithTag": "探索带有 {0} 标签的帖子",
"navPostsCaptionWithCategory": "探索被分类为 {0} 的帖子",
"indexIntroduce": "一家充满活力的软件公司,创造了人人喜爱的精彩软件。",
"indexProductListHint": "在这里看看我们的一些产品",
"indexActivities": "动态",

View File

@ -41,8 +41,18 @@
</span>
</div>
<div v-if="post.tags?.length > 0" class="text-xs text-grey flex flex-row gap-1 mb-3">
<span v-for="tag in post.tags">#{{ tag.alias }}</span>
<div
v-if="post.tags?.length > 0"
class="text-xs text-grey flex flex-row gap-1 mb-3"
>
<nuxt-link
v-for="tag in post.tags"
:to="`/posts/tags/${tag.alias}`"
class="hover:underline hover:underline-dotted"
@click.stop
>
#{{ tag.alias }}
</nuxt-link>
</div>
<div class="text-xs text-grey flex flex-col mb-5">

View File

@ -0,0 +1,34 @@
<template>
<v-container class="content-container mx-auto">
<div class="my-3 mx-[3.5ch]">
<h1 class="text-2xl">{{ t("navPosts") }}</h1>
<span>{{ t("navPostsCaptionWithCategory", [`#${route.params.slug}`]) }}</span>
</div>
<post-list :category="route.params.slug?.toString()" />
</v-container>
</template>
<script setup lang="ts">
const { t } = useI18n()
const route = useRoute()
useHead({
title: t("navActivity"),
})
useSeoMeta({
title: t("navActivity"),
ogTitle: t("navActivity"),
description: t("navActivityCaption"),
ogDescription: t("navActivityCaption"),
ogType: "website",
})
</script>
<style scoped>
.content-container {
max-width: 70ch !important;
}
</style>

View File

@ -0,0 +1,34 @@
<template>
<v-container class="content-container mx-auto">
<div class="my-3 mx-[3.5ch]">
<h1 class="text-2xl">{{ t("navPosts") }}</h1>
<span>{{ t("navPostsCaptionWithTag", [`#${route.params.slug}`]) }}</span>
</div>
<post-list :tag="route.params.slug?.toString()" />
</v-container>
</template>
<script setup lang="ts">
const { t } = useI18n()
const route = useRoute()
useHead({
title: t("navActivity"),
})
useSeoMeta({
title: t("navActivity"),
ogTitle: t("navActivity"),
description: t("navActivityCaption"),
ogDescription: t("navActivityCaption"),
ogType: "website",
})
</script>
<style scoped>
.content-container {
max-width: 70ch !important;
}
</style>