vue-website/pages/blog-index.vue

71 lines
1.8 KiB
Vue
Raw Normal View History

<template>
<main>
<a href="/"><-- Return Home</a>
<h1>Tom's Blog</h1>
2024-07-30 12:57:40 +10:00
<p class="no-margin" v-if="qSupplied">Selected Tag: <strong>{{query}}</strong> <a v-if="qSupplied" href="blog-index">(Clear Search)</a></p>
<p class="no-margin">Tag Search:
2024-07-28 21:30:28 +10:00
<a href="blog-index?tag=Programming">Programming</a> -
2024-07-30 15:02:00 +10:00
<a href="blog-index?tag=Godot">Godot</a> -
<a class="no-posts" href="blog-index?tag=Tech">Tech</a> -
<a class="no-posts" href="blog-index?tag=Queerness">Queerness</a> -
<a class="no-posts" href="blog-index?tag=Mental Health">Mental Health</a>
2024-07-28 21:30:28 +10:00
</p>
2024-07-30 12:57:40 +10:00
<hr>
<TextCard v-for="post in data"
:key="post.id"
:href="post._path"
:heading="post.title"
:subheading="post.date"
:description="post.description"
:id="post.id"
2024-07-28 21:30:28 +10:00
:tags="post.tags"
/>
</main>
</template>
<script lang="ts" setup>
2024-07-30 15:02:00 +10:00
useSeoMeta({
title: "Blog",
ogTitle: "Blog",
description: "I write about random things sometimes",
ogDescription: "I write about random things sometimes",
});
2024-07-28 21:30:28 +10:00
// const route = useRoute()
// const { data: tagSearch } = await useFetch(`/api/mountains/${route.params.slug}`)
var query : string = String(useRoute().query.tag)
var qSupplied : boolean = false
2024-07-30 15:02:00 +10:00
// console.log (query == 'undefined')
2024-07-28 21:30:28 +10:00
if (query == 'undefined'){
query = ''
2024-07-30 15:02:00 +10:00
// console.log('no tag supplied')
2024-07-28 21:30:28 +10:00
}
else{
2024-07-30 15:02:00 +10:00
// console.log('tag successful')
2024-07-28 21:30:28 +10:00
qSupplied = true
}
var { data } = await useAsyncData('home', () => queryContent('blog').where({ tags: { $contains: query } }).sort({id:-1}).find())
</script>
<style>
main {
display: flex;
flex-direction: column;
align-items: center;
padding: 2rem;
margin-top: 3.5rem;
2024-07-30 12:57:40 +10:00
gap: 0rem;
}
.no-margin{
margin: 0
}
2024-07-30 15:02:00 +10:00
.no-posts{
color: gray;
}
</style>