diff --git a/src/components/Sections/Blog.css b/src/components/Sections/Blog.css index 60cca53..ff8fc7e 100644 --- a/src/components/Sections/Blog.css +++ b/src/components/Sections/Blog.css @@ -1088,20 +1088,30 @@ margin: 0; } +.toc-item-wrap { + border-bottom: 1px solid rgba(255, 255, 255, 0.05); +} + +.toc-item-wrap:last-child { + border-bottom: none; +} + .toc-item { display: flex; align-items: flex-start; gap: 0.75rem; + width: 100%; padding: 0.75rem 0; - border-bottom: 1px solid rgba(255, 255, 255, 0.05); + margin: 0; + background: none; + border: none; cursor: pointer; + text-align: left; + font: inherit; + color: inherit; transition: all 0.2s; } -.toc-item:last-child { - border-bottom: none; -} - .toc-item:hover { padding-left: 0.5rem; } @@ -1114,6 +1124,12 @@ color: #ffffff; } +.toc-item:focus-visible { + outline: 2px solid rgba(69, 89, 220, 0.6); + outline-offset: 2px; + border-radius: 4px; +} + .toc-number { font-size: 0.75rem; font-weight: 700; @@ -1140,6 +1156,7 @@ .content-section { margin-bottom: 3rem; + scroll-margin-top: 100px; } .section-heading { diff --git a/src/components/Sections/BlogDetail.jsx b/src/components/Sections/BlogDetail.jsx index 2a4ae1b..c55226d 100644 --- a/src/components/Sections/BlogDetail.jsx +++ b/src/components/Sections/BlogDetail.jsx @@ -62,34 +62,33 @@ const BlogDetail = () => { ); } - // ✅ Normalized content - const content = { - toc: blog.content?.toc ?? [ - "Introduction", - "Overview", - "Key Points", - "Analysis", - "Conclusion", - ], - sections: blog.content?.sections ?? [ - { - heading: "Introduction", - text: - blog.excerpt || - "This article provides insights into the latest cryptocurrency trends.", - }, - { - heading: "Overview", - text: "This article is currently being prepared with detailed analysis and insights.", - }, - ], + // Sections are the single source of truth for body + TOC (avoids toc/section count mismatches) + const sections = + blog.content?.sections?.length > 0 + ? blog.content.sections + : [ + { + heading: "Introduction", + text: + blog.excerpt || + "This article provides insights into the latest cryptocurrency trends.", + }, + { + heading: "Overview", + text: + "This article is currently being prepared with detailed analysis and insights.", + }, + ]; + + const scrollToSection = (index) => { + document + .getElementById(`blog-section-${index}`) + ?.scrollIntoView({ behavior: "smooth", block: "start" }); }; // Demo views const views = Math.floor(Math.random() * 2000) + 500; - // Handlers - // Handlers const handleBookmark = async () => { if (!currentUser) { toast.error("Please login to bookmark articles"); @@ -197,12 +196,18 @@ const BlogDetail = () => {
{section.text}