From 36829ce003902f36991b5ad39f3f07c0d7ab5f72 Mon Sep 17 00:00:00 2001 From: jupiterBill Date: Fri, 17 Nov 2023 00:45:44 +0100 Subject: [PATCH] table of contents --- pages/blog/[id].js | 61 +++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/pages/blog/[id].js b/pages/blog/[id].js index 65c93ac..0fe0b9f 100644 --- a/pages/blog/[id].js +++ b/pages/blog/[id].js @@ -20,8 +20,8 @@ const client = contentful.createClient({ 'heading-5': (node, children) =>
{children}
, 'heading-6': (node, children) =>
{children}
, 'paragraph': (node, children) =>

{children}

, - 'unordered-list': (node, children) => , - 'ordered-list': (node, children) =>
    {children}
, + 'unordered-list': (node, children) => , + 'ordered-list': (node, children) =>
    {children}
, 'list-item': (node, children) =>
  • {children}
  • , 'blockquote': (node, children) =>
    {children}
    , }, @@ -33,30 +33,41 @@ export default function Data({blogData}){ return
    Loading...
    ; } return ( -
    -
    -
    - {blogData ? documentToReactComponents(blogData.fields.title) : "loading..."} +
    +
    +
    + {blogData ? documentToReactComponents(blogData.fields.title) : 'loading...'} +
    +
    + +
    + Blog Image +
    + +
    + {blogData ? blogData.fields.author : '...'} .{' '} + {new Date(blogData.sys.updatedAt).toLocaleString()} +
    + + {/* Table of Contents Section */} +
    +

    Table Of Contents

    + {blogData ? documentToReactComponents(blogData.fields.tableOfContents,options):"loading"} +
    + + +
    + {blogData ? documentToReactComponents(blogData.fields.content, options) : 'Loading'} +
    + + +
    -
    -
    - Blog Image -
    -
    - {blogData? blogData.fields.author: "..."} . {new Date(blogData.sys.updatedAt).toLocaleString()} -
    -
    - {blogData ? documentToReactComponents(blogData.fields.content,options) :"Loading"} -
    - - - -
    - ) + ); } export async function getStaticPaths() {