diff --git a/app/pages/portfolio/index.vue b/app/pages/portfolio/index.vue index 7d49675..8b6a4aa 100644 --- a/app/pages/portfolio/index.vue +++ b/app/pages/portfolio/index.vue @@ -7,11 +7,39 @@ useSeoMeta({ description: t('description'), }) -const {data: writings} = await useAsyncData('all-portfolio', () => queryContent('/portfolio').sort({publishedAt: -1}).without('body').find()) +const tagFilter = ref(undefined) + +const {data: writings, refresh} = await useAsyncData('all-portfolio', () => queryContent('/portfolio') + .sort({publishedAt: -1}) + .where({ + tags: {$contains: tagFilter.value}, + }) + .without('body') + .find()) + +watch(tagFilter, async () => await refresh()) + +const tags = [{ + label: 'All', + icon: 'i-ph-books-duotone', +}, { + label: 'Articles', + icon: 'i-ph-pencil-line-duotone', + tag: 'article', +}, { + label: 'Projects', + icon: 'i-ph-briefcase-duotone', + tag: 'project', +}] + +function updateTag(index: number) { + const tag = tags[index] + tagFilter.value = tag?.label === 'All' ? undefined : tag?.tag +}