Giter Club home page Giter Club logo

toc-plugin's Introduction

TOC Plugin

A JavaScript plugin that generates a Table of Contents listing based off the HTML header elements within a document. Based off of the plugin built in the Vanilla JS Crash Course by Chris Ferdinandi.

Getting Started

Include the plugin's script files

This code adds the required files to the webpage. These files need to be included before initializing the slider.

<script src="js/toc-script.js"></script>

Initialize the plugin

This code tells the webpage to start the plugin setup. Without this code the plugin would not be visible on the page.

<script>
  tocPlugin.init(myPluginOptionsObj);
</script>

Optionally pass in user configurations

Pass in a JS object with configuration options.

<script>
  var myPluginOptionsObj = {
    // Selectors
    selectorHeaders: 'h2, h3, h4, h5, h6',
    selectorTocs: '[data-toc]',

    // Classes
    initClass: 'js-toc-custom',
  }
  tocPlugin.init(myPluginOptionsObj);
</script>

Create the HTML for the plugin

This is the code that the slider plugin will use to generate the Table of Contents.

<div data-toc></div>

Credits

toc-plugin's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

toc-plugin's Issues

plugin extension ideas

Ideas

Ideas to extend the project:

  • Markdown converter
  • Medium-like content intereactivity (e.g. highlighting quotes, social share, comments, ect.)
  • Styles for certain elements: text headers, sub-header, horizontal rules, blockquote, code, hidden-show for answers (like stack overflow), embeeded code gist/code editor, ect.)
  • Add <section> elements to wrap article/post content for use in a accordion styled nav menu
  • GitBooks demo
  • Footnotes support
  • Download icons based on type of download
  • Ajax loaded comments/contents with spinner
  • Loading CSS
  • Advertising areas, injected sidebars/asides in content?
  • Add more standardized options/settings object naming conventions
  • Add "time to read" feature
  • Add Header/sub-header title count
  • Add a separate util.js dependency for accessing commonly used "helper" functions and as not to clutter up the plugin script itself
  • Add gist like features with URL stuff

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.