Skip to content

Commit 6abb7f0

Browse files
committed
fix page navigation error and improve tagging
1 parent c7d1947 commit 6abb7f0

File tree

7 files changed

+38
-12
lines changed

7 files changed

+38
-12
lines changed

articles/components.md

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ slug: components-testing
88
author: 'Godwin peter .O'
99
draft: false
1010
navigation: true
11+
tags: Tech, Blog, Vue
12+
publishedAt: 2024-04-08
1113
image:
1214
src: '/assets/image.jpg'
1315
alt: 'placeholder'

articles/draft-content/index.md

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ description:
77
slug: draft-root
88
draft: false
99
navigation: true
10+
tags: Tech, Blog, Vue
11+
publishedAt: 2024-04-08
1012
---
1113

1214
Nested index sample

articles/draft-content/nested-test.md

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ description: Lorem ipsum dolor sit amet, consectetur adipisicing elit. Inventore
66
slug: nested-document-test
77
draft: false
88
navigation: true
9+
tags: Tech, Blog, Vue
10+
publishedAt: 2024-04-08
911
---
1012

1113
Nested content sample

articles/welcome.md

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ slug: welcome-content
88
author: 'Godwin peter .O'
99
draft: false
1010
navigation: true
11+
tags: Tech, Blog, Vue
12+
publishedAt: 2024-04-08
1113
---
1214

1315
Summary of welcome content.

nuxt.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export default defineNuxtConfig({
8282
},
8383
content: {
8484
navigation: {
85-
fields: ['author', 'publishedAt'],
85+
fields: ['author', 'publishedAt', 'tags'],
8686
},
8787
// TODO: Review if necessary
8888
sources: {

pages/blog/[...slug].vue

+25-7
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ if (page.value !== null) {
2121
twitterCard: 'summary_large_image',
2222
});
2323
}
24+
25+
const processTags = (value?: string): string[] => {
26+
if (value === undefined) return [];
27+
const items = value.split(',');
28+
29+
return items.length > 7 ? items.slice(0, items.length - 1) : items;
30+
};
31+
32+
console.log(page.value);
2433
</script>
2534

2635
<template>
@@ -30,15 +39,24 @@ if (page.value !== null) {
3039
<div class="space-y-8">
3140
<div class="text-center p-8 border-b">
3241
<h1 class="text-5xl font-bold mb-4">{{ doc.title }}</h1>
33-
<p class="text-base font-light line-clamp-2">
42+
<p class="text-base font-light line-clamp-2 lg:px-32">
3443
{{ doc.description }}
3544
</p>
36-
<div class="mt-4">
37-
<span
38-
class="text-sm uppercase font-normal rounded-lg bg-blue-100 px-3 py-1.5"
39-
>
40-
{{ formatDate(doc.createdAt) }}
41-
</span>
45+
<div class="mt-4 space-y-2">
46+
<div class="px-1 space-x-2">
47+
<span
48+
v-for="tag in processTags(doc.tags)"
49+
:key="tag"
50+
class="text-sm text-blue-500 font-normal rounded-lg bg-blue-100 px-3 py-1.5"
51+
>
52+
{{ tag }}
53+
</span>
54+
</div>
55+
<div class="">
56+
<span class="text-sm uppercase font-normal">
57+
{{ formatDate(doc.publishedAt) }}
58+
</span>
59+
</div>
4260
</div>
4361
<!-- <span>Updated: {{ formatDate(doc.updatedAt) }}</span> -->
4462
</div>

pages/blog/index.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ useSeoMeta({
4444
v-if="articles !== null && articles.length > 0"
4545
class="mx-auto grid max-w-2xl grid-cols-1 gap-x-8 gap-y-16 border-t border-gray-200 sm:mt-2 sm:pt-4 lg:mx-0 lg:max-w-none lg:grid-cols-3"
4646
>
47-
<nuxt-link v-for="post in articles" :key="post.id" :to="root + post.slug">
47+
<a v-for="post in articles" :key="post.id" :href="root + post.slug">
4848
<article
4949
class="flex max-w-sm rounded-xl flex-col items-start justify-between overflow-hidden hover:bg-indigo-10 hover:scale-105 hover:shadow-2xl transition shadow transform duration-300"
5050
>
@@ -67,8 +67,8 @@ useSeoMeta({
6767
</p>
6868
</section>
6969
<footer class="flex items-center gap-x-2 text-xs mt-2 py-2 px-3">
70-
<time :datetime="post.createdAt" class="text-gray-500">{{
71-
formatDate(post.createdAt)
70+
<time :datetime="post.publishedAt" class="text-gray-500">{{
71+
formatDate(post.publishedAt)
7272
}}</time>
7373
<span
7474
:to="'#'"
@@ -77,7 +77,7 @@ useSeoMeta({
7777
>
7878
</footer>
7979
</article>
80-
</nuxt-link>
80+
</a>
8181
</div>
8282
<div v-else class="text-2xl text-center">{{ 'Not Found' }}</div>
8383
</div>

0 commit comments

Comments
 (0)