[components/toc][s]: minor fixes

This commit is contained in:
olayway 2022-05-26 20:58:00 +02:00
parent 034bb1eb3d
commit 11bd57fcc7
3 changed files with 2 additions and 23 deletions

View File

@ -3,12 +3,12 @@ import React, { useEffect, useState } from 'react';
export const Heading = ({ level, observer }) => (props) => {
useEffect(() => {
// start observing heading's intersection with the bounding box set by observer's `rootMargin`
if (observer) {
observer.observe(document.getElementById(props.id));
}
});
return React.createElement(`h${level}`, {
...props,
className: "scroll-mt-16 cursor-pointer"

View File

@ -3,7 +3,7 @@ import Head from 'next/head'
import siteConfig from '../config/siteConfig'
import navLinks from '../config/navLinks'
import Nav from './Nav'
import Sidebar from './Sidebar'
// import Sidebar from './Sidebar'
export default function Layout({ children }) {

View File

@ -1,21 +0,0 @@
import Link from 'next/link'
export const Toc = ({ headings }) => {
return (
<nav>
<h4>
On this page
</h4>
{ headings.map(({url, title, level}, i) => (
<div key={i} className={`flex leading-5 pl-${(level-1)*4}`}>
<Link href={`#${url}`} >
<a className="py-1 text-slate-400 hover:text-white no-underline transition-colors">
{ title }
</a>
</Link>
</div>
))}
</nav>
)
}