added tag search to blog
This commit is contained in:
parent
bb7e3329f3
commit
ebf28f8386
4 changed files with 27 additions and 3 deletions
|
|
@ -3,6 +3,12 @@
|
|||
<a href="/"><-- Return Home</a>
|
||||
<h1>Tom's Blog</h1>
|
||||
|
||||
<p>Tag Search:
|
||||
<a v-if="qSupplied" href="blog-index">Clear Search</a> -
|
||||
<a href="blog-index?tag=Programming">Programming</a> -
|
||||
<a href="blog-index?tag=GameDev">Game Dev</a> -
|
||||
<a href="blog-index?tag=Queer">Queer Stuff</a>
|
||||
</p>
|
||||
|
||||
<TextCard v-for="post in data"
|
||||
:key="post.id"
|
||||
|
|
@ -11,6 +17,7 @@
|
|||
:subheading="post.date"
|
||||
:description="post.description"
|
||||
:id="post.id"
|
||||
:tags="post.tags"
|
||||
/>
|
||||
|
||||
|
||||
|
|
@ -19,7 +26,20 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
var { data } = await useAsyncData('home', () => queryContent('blog').sort({id:-1}).find())
|
||||
// const route = useRoute()
|
||||
// const { data: tagSearch } = await useFetch(`/api/mountains/${route.params.slug}`)
|
||||
var query : string = String(useRoute().query.tag)
|
||||
var qSupplied : boolean = false
|
||||
console.log (query == 'undefined')
|
||||
if (query == 'undefined'){
|
||||
query = ''
|
||||
console.log('no tag supplied')
|
||||
}
|
||||
else{
|
||||
console.log('tag successful')
|
||||
qSupplied = true
|
||||
}
|
||||
var { data } = await useAsyncData('home', () => queryContent('blog').where({ tags: { $contains: query } }).sort({id:-1}).find())
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue