Skip to content

Commit c56dcee

Browse files
feat: improve blogs visual
1 parent b19c647 commit c56dcee

File tree

4 files changed

+44
-6
lines changed

4 files changed

+44
-6
lines changed

app/layouts/default.vue

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="w-full font-normal font-[Inter_Variable] prose-neutral dark:prose-invert">
33
<div>
44
<navbar />
5-
<div class="mx-a lt-md:px-4 md:prose" :class="[$style.dashed_link]">
5+
<div class="mx-a lt-md:px-4 md:prose" :class="[$style.dashed_link, $style.no_header_underline]">
66
<slot />
77
<div class="h-8" />
88
<cd />
@@ -17,4 +17,12 @@
1717
--at-apply: "underline-dashed hover:underline-solid"
1818
}
1919
}
20+
21+
.no_header_underline {
22+
h1, h2, h3, h4, h5, h6 {
23+
a {
24+
--at-apply: 'no-underline'
25+
}
26+
}
27+
}
2028
</style>

app/pages/blogs/[...slugs].vue

+31-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,32 @@
11
<script setup lang="ts">
2+
import type { MarkdownNode, ParsedContent } from '@nuxt/content'
3+
4+
function parseNode(node: MarkdownNode): number {
5+
let wordCount = 0
6+
7+
if (node.type === 'text' && node.value) {
8+
wordCount += node.value.split(' ').length
9+
}
10+
11+
for (const child of node.children ?? []) {
12+
wordCount += parseNode(child)
13+
}
14+
15+
return wordCount
16+
}
17+
18+
function getWordCount(parsedContent: ParsedContent): number {
19+
let wordCount = 0
20+
21+
if (parsedContent.body) {
22+
for (const child of parsedContent.body.children) {
23+
wordCount += parseNode(child)
24+
}
25+
}
26+
27+
return wordCount
28+
}
29+
230
const ContentNotFound = defineComponent({
331
setup() {
432
showError({
@@ -14,8 +42,9 @@ const ContentNotFound = defineComponent({
1442
<template #default="{ doc }">
1543
<div class="pb-4">
1644
<h1>{{ doc.title }}</h1>
17-
<p class="op-70">
18-
{{ useDateFormat(doc.date, 'ddd, DD MMM YYYY') }}
45+
<p class="op-70 divide-x *:px-2 first:*:pl-0">
46+
<span>{{ useDateFormat(doc.date, 'ddd, DD MMMM YYYY') }}</span>
47+
<span>{{ getWordCount(doc) }} words</span>
1948
</p>
2049
</div>
2150
<content-renderer :value="doc" />

app/pages/blogs/index.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ useHead({ title: 'Blogs' })
1313
v-for="blog in list.sort((a, b) => +new Date(b.date) - +new Date(a.date))"
1414
:key="blog._path"
1515
>
16-
<div class="flex flex-col items-start py-3 md:(grid-cols-[75%,auto] flex-row pt-2)">
16+
<div class="flex flex-col items-start py-2 md:flex-row">
1717
<h3 class="my-2 flex-auto md:m-a">
1818
<nuxt-link :to="blog._path">
1919
{{ blog.title }}
2020
</nuxt-link>
2121
</h3>
22-
<p class="my-0 op-70 md:m-a">
23-
{{ useDateFormat(blog.date, 'DD MMM YYYY') }}
22+
<p class="my-0 op-70 md:(my-a ml-12 min-w-fit)">
23+
{{ useDateFormat(blog.date, 'DD MMMM YYYY') }}
2424
</p>
2525
</div>
2626
</template>

nuxt.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export default defineNuxtConfig({
6565
},
6666
manifest: {
6767
background_color: '#FFF',
68+
theme_color: '#000',
6869
display: 'minimal-ui',
6970
lang: 'en',
7071
orientation: 'portrait-primary',

0 commit comments

Comments
 (0)