[components/toc][s]: minor fixes
This commit is contained in:
parent
034bb1eb3d
commit
11bd57fcc7
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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 }) {
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
)
|
||||
}
|
||||
Loading…
Reference in New Issue