-
—
-
-
-
—
- {{ simpleDateFormat(article.metadata.updated) }}
+
+
+  
+
+  —
+
+
+  
+
+
+  —
+
+ {{ simpleDateFormat(article.metadata.updated) }}
+
+
+ —
+
+
![]()
-import { ref, onBeforeMount, onUpdated, onMounted } from 'vue'
-import { listArticles, updateDynamicContent } from '@lib/articles'
-import type { ArticleMetadata } from '@interfaces'
-import { simpleDateFormat } from '@lib/dates'
-import { HOME_COUNT, PROD, PUBLISHED_ON, TITLE } from '@lib/config'
-import { stripHTML } from '@lib/strings'
+import { ref, onBeforeMount, onUpdated, onMounted, watch } from "vue";
+import { listArticles, updateDynamicContent } from "@lib/articles";
+import type { ArticleMetadata } from "@interfaces";
+import { HOME_COUNT, PROD, TITLE } from "@lib/config";
+import { stripHTML } from "@lib/strings";
+import ArticleItem from "@/components/ArticleItem.vue";
+import { useRoute } from 'vue-router'
-const articles = ref
([])
-const loading = ref(true)
+const articles = ref([]);
+const filteredArticles = ref([]);
+const loading = ref(true);
+const route = useRoute();
+
+function filterArticles() {
+ if (route.query.tag) {
+ filteredArticles.value = articles.value
+ .filter((metadata) => metadata.tags.includes(route.query.tag as string));
+ } else {
+ filteredArticles.value = articles.value
+ .slice(0, HOME_COUNT);
+ }
+}
onBeforeMount(async () => {
const newArticles = (await listArticles())
.filter((metadata) => (!metadata.draft || !PROD) && metadata.path)
- .slice(0, HOME_COUNT)
- articles.value.splice(0, articles.value.length, ...newArticles)
- window.document.title = stripHTML(TITLE) + ' — Home'
- loading.value = false
- await updateDynamicContent()
+ articles.value.splice(0, articles.value.length, ...newArticles);
+ filterArticles();
+ window.document.title = stripHTML(TITLE) + " — Home";
+ loading.value = false;
+ await updateDynamicContent();
+});
+
+watch(() => route.query.tag, () => {
+ filterArticles();
})
-onMounted(updateDynamicContent)
-onUpdated(updateDynamicContent)
+
+onMounted(updateDynamicContent);
+onUpdated(updateDynamicContent);
-
+
-
-
-
-
-
+