Render TOC items as divs to eliminate bullets
This commit is contained in:
@@ -13,8 +13,8 @@ interface TocItem {
|
|||||||
export function PostToc() {
|
export function PostToc() {
|
||||||
const [items, setItems] = useState<TocItem[]>([]);
|
const [items, setItems] = useState<TocItem[]>([]);
|
||||||
const [activeId, setActiveId] = useState<string | null>(null);
|
const [activeId, setActiveId] = useState<string | null>(null);
|
||||||
const listRef = useRef<HTMLUListElement | null>(null);
|
const listRef = useRef<HTMLDivElement | null>(null);
|
||||||
const itemRefs = useRef<Record<string, HTMLLIElement | null>>({});
|
const itemRefs = useRef<Record<string, HTMLDivElement | null>>({});
|
||||||
const [indicator, setIndicator] = useState({ top: 0, opacity: 0 });
|
const [indicator, setIndicator] = useState({ top: 0, opacity: 0 });
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -104,19 +104,19 @@ export function PostToc() {
|
|||||||
style={{ top: `${indicator.top}px`, opacity: indicator.opacity }}
|
style={{ top: `${indicator.top}px`, opacity: indicator.opacity }}
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
/>
|
/>
|
||||||
<ul
|
<div
|
||||||
ref={listRef}
|
ref={listRef}
|
||||||
className="space-y-1"
|
className="space-y-1"
|
||||||
style={{ listStyleType: 'none', paddingLeft: 0, margin: 0 }}
|
role="list"
|
||||||
>
|
>
|
||||||
{items.map((item) => (
|
{items.map((item) => (
|
||||||
<li
|
<div
|
||||||
key={item.id}
|
key={item.id}
|
||||||
ref={(el) => {
|
ref={(el) => {
|
||||||
itemRefs.current[item.id] = el;
|
itemRefs.current[item.id] = el;
|
||||||
}}
|
}}
|
||||||
|
role="listitem"
|
||||||
className={`relative ${item.depth === 3 ? 'pl-3' : 'pl-0'}`}
|
className={`relative ${item.depth === 3 ? 'pl-3' : 'pl-0'}`}
|
||||||
style={{ listStyleType: 'none' }}
|
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
href={`#${item.id}`}
|
href={`#${item.id}`}
|
||||||
@@ -130,9 +130,9 @@ export function PostToc() {
|
|||||||
<FontAwesomeIcon icon={faCircle} className="h-1.5 w-1.5 text-slate-300" aria-hidden="true" />
|
<FontAwesomeIcon icon={faCircle} className="h-1.5 w-1.5 text-slate-300" aria-hidden="true" />
|
||||||
{item.text}
|
{item.text}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</div>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user