8 changed files with 76 additions and 35 deletions
			
			
		| @ -1,13 +1,19 @@ | |||||||
| import { defineContentConfig, defineCollection } from '@nuxt/content' | import { defineContentConfig, defineCollection, z } from '@nuxt/content' | ||||||
| 
 | 
 | ||||||
| // Lookup resolved from path: rootDir/content
 | // Lookup resolved from path: rootDir/content
 | ||||||
| // see: https://github.com/nuxt/content/issues/3161
 | // see: https://github.com/nuxt/content/issues/3161
 | ||||||
| 
 | 
 | ||||||
| export default defineContentConfig({ | export default defineContentConfig({ | ||||||
|   collections: { | 	collections: { | ||||||
|     content: defineCollection({ | 		content: defineCollection({ | ||||||
|       type: "page", | 			type: "page", | ||||||
|       source: "**/*.md" | 			source: "**/*.md", | ||||||
|     }) | 			schema: z.object({ | ||||||
|   } | 				date: z.date(), | ||||||
|  | 				img: z.string(), | ||||||
|  | 				sub: z.string(), | ||||||
|  | 				tags: z.array(z.string()), | ||||||
|  | 			}) | ||||||
|  | 		}) | ||||||
|  | 	} | ||||||
| }) | }) | ||||||
|  | |||||||
| @ -1,6 +1,10 @@ | |||||||
| --- | --- | ||||||
| title: "My Second Blog Post" | title: "My Second Blog Post" | ||||||
| description: "This is another article." | description: "This is another article." | ||||||
|  | navigation: false | ||||||
|  | sub: "Bash" | ||||||
|  | img: "/img/personal-website/reset-password.png" | ||||||
|  | date: "2025-03-02" | ||||||
| --- | --- | ||||||
| 
 | 
 | ||||||
| This is another article. | This is another article. | ||||||
|  | |||||||
| @ -1,18 +1,47 @@ | |||||||
| <template> | <template> | ||||||
| 	<div> | 	<div> | ||||||
| 		<h1>Articles</h1> | 		<h1>Articles</h1> | ||||||
| 		<ul> |  | ||||||
| 			<li v-for="article in articles" :key="article.path"> |  | ||||||
| 				<NuxtLink :to="article.path">{{ article.title }}</NuxtLink> |  | ||||||
| 			</li> |  | ||||||
| 		</ul> |  | ||||||
| 
 | 
 | ||||||
| 		<div v-for="article in articles" :key="article.path"> | 		<div class="row pt-5" v-for="article in articles" :key="article.path"> | ||||||
| 			<pre>{{ article }}</pre> | 			<div class="col-5 col-lg-4 col-xl-3"> | ||||||
|  | 				<NuxtLink v-if="article.img" :to="article.path"> | ||||||
|  | 					<img class="img-fluid" :src="article.img as string" :alt="article.title" loading="lazy" :title="article.title"> | ||||||
|  | 				</NuxtLink> | ||||||
|  | 			</div> | ||||||
|  | 			<div class="col-7 col-lg-8 col-xl-9"> | ||||||
|  | 				<NuxtLink v-if="article.img" :to="article.path"> | ||||||
|  | 					<h4><strong>{{ article.title }}</strong></h4> | ||||||
|  | 				</NuxtLink> | ||||||
|  | 				{{ article.description }}<br> | ||||||
|  | 				<i><small>{{ article.sub }}</small></i> | ||||||
|  | 			</div> | ||||||
| 		</div> | 		</div> | ||||||
|  | 
 | ||||||
|  | 		<template v-if="isDev"> | ||||||
|  | 			<br> | ||||||
|  | 			<div v-for="article in articles" :key="article.path"> | ||||||
|  | 				<pre>{{ article }}</pre> | ||||||
|  | 			</div> | ||||||
|  | 		</template> | ||||||
| 	</div> | 	</div> | ||||||
| </template> | </template> | ||||||
| 
 | 
 | ||||||
|  | <style scoped> | ||||||
|  | a { | ||||||
|  | 	text-decoration: none !important; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | a h4 { | ||||||
|  | 	color: var(--bs-body-color); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | a h4:hover { | ||||||
|  | 	color: var(--bs-link-hover-color); | ||||||
|  | } | ||||||
|  | </style> | ||||||
|  | 
 | ||||||
| <script setup lang="ts"> | <script setup lang="ts"> | ||||||
| const { data: articles } = await useAsyncData("articles", () => queryCollection("content").all()) | import { useAsyncData, queryCollection } from "#imports"; | ||||||
|  | 
 | ||||||
|  | const { data: articles } = await useAsyncData("articles", () => queryCollection("content").order("date", "DESC").all()) | ||||||
| </script> | </script> | ||||||
|  | |||||||
					Loading…
					
					
				
		Reference in new issue