-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
[...slug].vue
111 lines (100 loc) · 3 KB
/
[...slug].vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<script setup lang="ts">
const appConfig = useAppConfig()
const route = useRoute()
/**
*
* fetch the article data based on the current route path
*
*/
const { data, pending } = await useAsyncData(`${route.path}`, () => queryContent(route.path).findOne())
/**
*
* catalog (it's the toc for markdown article)
*
*/
const showCatalog = useState<Boolean>('showCatalog', () => {
return appConfig.bloginote.articlePage.showCatalog
})
const showFooterNavMoreOptions = useState('showFooterNavMoreOptions')
const showFooterNavThemeOptions = useState('showFooterNavThemeOptions')
</script>
<template>
<div>
<Head>
<Title>{{ data?.title || 'Article' }}</Title>
</Head>
<NuxtLayout
name="base"
:footer-catalog="data?.body?.toc && data.body.toc.links.length > 0"
>
<template
v-if="!pending && data?._type === 'markdown' && data?.body?.toc && data.body.toc.links.length > 0"
#header-nav-right
>
<button
title="toggle catalog show or hide"
class="w-10 h-10 flex justify-center items-center border rounded-md transition-colors duration-300"
:class="showCatalog ? 'text-purple-500 bg-purple-100 hover:bg-purple-50 border-purple-200' : 'text-gray-500 bg-white hover:bg-gray-100 border-gray-200'"
@click="showCatalog = !showCatalog"
>
<IconCustom
name="entypo:list"
class="w-5 h-5"
/>
</button>
</template>
<MarkdownPost
v-if="!pending && data?._type === 'markdown'"
:data="data"
class="container mx-auto px-6 md:px-12 py-12 lg:max-w-4xl"
/>
<div
v-else-if="!pending && data && (data._type === 'json' || data._type==='csv')"
class="container mx-auto"
>
<div
class="json-content-container max-h-[calc(100vh*0.8)] m-6 p-4 border rounded-lg overflow-auto"
>
<pre>{{ data }}</pre>
</div>
</div>
<template
v-if="!pending && data?._type === 'markdown' && data?.body?.toc && data.body.toc.links.length > 0"
#footer-nav-right
>
<button
v-show="!showFooterNavMoreOptions && !showFooterNavThemeOptions"
class="grow px-2 py-3 flex justify-center items-center space-y-1 bg-gray-50"
:class="showCatalog ? 'text-purple-500' : 'text-gray-500'"
@click="showCatalog = !showCatalog"
>
<div class="flex flex-col justify-center items-center gap-1">
<IconCustom
name="entypo:list"
class="w-6 h-6"
/>
<p class="text-xs">
Catalog
</p>
</div>
</button>
</template>
</NuxtLayout>
</div>
</template>
<style scope lang="scss">
.json-content-container {
&::-webkit-scrollbar {
width: 10px;
height: 10px;
}
&::-webkit-scrollbar-thumb {
background-color: #cbd5e1;
}
&::-webkit-scrollbar-thumb:hover {
background-color: #94a3b8;
}
}
</style>
<style lang="scss">
</style>