gitwtfhub

wtf is tableofcontent?

batuhankarasakal/tableofcontent — explained in plain English

Analysis updated 2026-05-18

13JavaScriptAudience · developerComplexity · 2/5Setup · easy

TL;DR

A JavaScript component that builds a sticky, hover-activated table of contents with image previews for portfolio websites.

Mindmap

mindmap
  root((tableofcontent))
    What it does
      Sticky TOC nav
      Active section tracking
      Hover tooltips
      Image previews
    Tech stack
      JavaScript
      CSS
      Web Audio API
    Use cases
      Portfolio site navigation
      Project preview slider
    Audience
      Frontend developers
      Portfolio site builders
    Customization
      CSS variables
      Init options
    Accessibility
      Keyboard focus
      Reduced motion support

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Why would anyone build with this?

REASON 1

Add a sticky, scroll-aware table of contents to a portfolio site.

REASON 2

Show hover tooltips with project descriptions and rotating image previews.

REASON 3

Give visitors keyboard-accessible navigation between project sections.

What's in the stack?

JavaScriptCSSWeb Audio API

How it stacks up

batuhankarasakal/tableofcontent09catho/axonabdulrdeveloper/react--tic-tac-toe
Stars131313
LanguageJavaScriptJavaScriptJavaScript
Setup difficultyeasymoderateeasy
Complexity2/54/51/5
Audiencedeveloperresearcherdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you spin it up?

Difficulty · easy Time to first run · 5min

Wtf does this do

tableofcontent is a small JavaScript component you can drop into a portfolio website to build a sticky table of contents along the left edge of the page. As a visitor scrolls, it tracks which project section is currently active and highlights the matching link. Hovering or focusing on a link opens a dark tooltip that shows the project name and a short description, plus a rotating preview of images pulled from that section, so visitors get a quick look at each project without leaving the page. The component is plain JavaScript and CSS, no framework required. You install it by linking the stylesheet, writing a nav element with anchor links that match your section IDs, and calling an initProjectToc function from the included script. Preview images are gathered automatically from any element matching .project-shot img inside the linked section. Several options let you customize behavior: the CSS selectors used for the table of contents, links, and section images, how sensitive the active-section detection is, how often preview images rotate, whether smooth scrolling is enabled when a link is clicked, and whether hover and click sound effects play, built with the Web Audio API. Visual styling is controlled through CSS custom properties, covering things like the position of the table of contents, the width and height of the marker line next to each link, and the tooltip background color, so it can be restyled to match a different site without editing the component's core CSS. The project also pays attention to accessibility. Links are real anchor elements rather than clickable divs, the active link is marked with aria-current, tooltips can be reached and triggered by keyboard focus, and both the sound effects and image slider motion respect the visitor's reduced-motion preference. A live demo is hosted on GitHub Pages, and the repository includes a local demo you can run with npm start. The project has 13 stars and is written in JavaScript.

Yoink these prompts

Prompt 1
Help me wire the tableofcontent component into my portfolio's HTML sections.
Prompt 2
Show me how to change the tooltip background color and TOC position using its CSS variables.
Prompt 3
Explain how initProjectToc's options like activeMarkerRatio and previewInterval affect behavior.
Prompt 4
Help me disable the sound effects and smooth scrolling in tableofcontent.

Frequently asked questions

wtf is tableofcontent?

A JavaScript component that builds a sticky, hover-activated table of contents with image previews for portfolio websites.

What language is tableofcontent written in?

Mainly JavaScript. The stack also includes JavaScript, CSS, Web Audio API.

How hard is tableofcontent to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is tableofcontent for?

Mainly developer.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.