Add table of content for blog page

Signed-off-by: Al Asad Nur Riyad <alasadnurriyad@Als-MacBook-Pro.local>
This commit is contained in:
Al Asad Nur Riyad
2023-08-03 01:17:54 +06:00
parent 15fa5fd755
commit 737a34dd9f

View File

@@ -17,6 +17,8 @@ const data = computed<BlogPost>(() => {
} }
}) })
const links = articles.body.toc.links
useHead({ useHead({
title: data.value.title || '', title: data.value.title || '',
meta: [ meta: [
@@ -74,7 +76,8 @@ useHead({
</script> </script>
<template> <template>
<main class="px-6 container max-w-5xl mx-auto"> <main class="px-6 container max-w-6xl mx-auto grid grid-cols-12 space-x-8">
<div class="col-span-12 lg:col-span-9">
<header> <header>
<h1 class="text-xl md:text-3xl lg:text-4xl m-7 font-bold text-center"> <h1 class="text-xl md:text-3xl lg:text-4xl m-7 font-bold text-center">
{{ data.title || '' }} {{ data.title || '' }}
@@ -111,5 +114,14 @@ useHead({
</template> </template>
</ContentRenderer> </ContentRenderer>
</div> </div>
</div>
<div class="lg:col-span-3 sticky top-28 h-96 p-2 hidden lg:block">
<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 underline text-md mb-3">
{{ link.text }}
</NuxtLink>
</div>
</main> </main>
</template> </template>