Add table of content for blog page and fixed minor issue

Signed-off-by: Al Asad Nur Riyad <alasadnurriyad@Als-MacBook-Pro.local>
This commit is contained in:
Al Asad Nur Riyad
2023-08-03 23:35:50 +06:00
parent 737a34dd9f
commit 992fee688d
7 changed files with 279 additions and 168 deletions

17
components/blog/Toc.vue Normal file
View File

@@ -0,0 +1,17 @@
<script setup lang="ts">
const { path } = useRoute()
const articles = await queryContent(path).findOne()
const links = articles.body.toc.links
</script>
<template>
<div class="lg:col-span-3 sticky top-28 h-96 p-2 hidden lg:block justify-self-end">
<h1 class="text-lg font-bold mb-4">
Table Of Content
</h1>
<NuxtLink v-for="link in links" :key="link.id" :to="`#${link.id}`" class="block text-md mb-3">
{{ link.text }}
</NuxtLink>
</div>
</template>