Skip to content

Instantly share code, notes, and snippets.

@aercolino
Last active March 16, 2016 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aercolino/e7f4eeb4bcbd37879819 to your computer and use it in GitHub Desktop.
Save aercolino/e7f4eeb4bcbd37879819 to your computer and use it in GitHub Desktop.
#nzymes Table of Contents: add one to any page

Table of Contents: add one to any page

These are my enzymes for the table of contents shown at http://andowebsit.es/blog/noteslog.com/nzymes/.

See Example 1: table-of-contents;example-1

This setup allows a post author to easily create and maintain a table of contents straight into the visual editor of a page. (See table-of-contents;toc-left.md and table-of-contents;toc-right.md) At the same time, the table of contents can be added to any other WordPRess place, so that it's shown when the context of that place is rendered by WordPress. (See table-of-contents;example-1.html)

{
"nzymes": "1_0_0",
"self": "1_0_0"
}
In a section, above the hr there is my contents and below it there is only my Table of Contents.
<hr />
{[ @table-of-contents;toc:post_content ]}{[ defer(15) ]}
<!--nextpage-->
In another section, above the hr there is my contents and below it there is only my Table of Contents.
<hr />
{[ @table-of-contents;toc:post_content ]}{[ defer(15) ]}
<table class="table-of-contents">
<tr>
<td>
{[ @table-of-contents;toc-left:post_content ]}
</td>
<td>
{[ @table-of-contents;toc-right:post_content ]}
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center;">
<a href="http://andowebsit.es/blog/noteslog.com/nzymes/">Nzymes</a> | <a href=
"https://wordpress.org/plugins/nzymes/">WordPress Plugin</a>
</td>
</tr>
</table>{[ @table-of-contents;copyright:post_content ]}
@aercolino
Copy link
Author

#enject Table of Contents

Summary

This is my setup for the table of contents shown here:

Details

  1. Create and organize links into your table of contents right from the WordPress editor.
    • Use different pages for different sections of your document (easy), or include the required HTML anchors to link to from a URL fragment (hard).
    • Split a big page into many smaller ones by using the <!--nextpage--> separator: subpages will be addressable individually with their own different URLs.
  2. Add toc, toc-left, toc-right, and copyright custom fields to a hosting page with a given slug.
  3. Cut one half of the links and replace it to the contents of toc-left; cut the other half of the links and replace it to the contents of toc-right.
  4. Replace the @repo reference into injection and toc with the correct reference to the slug of the hosting page.
  5. Copy the text of the injection and paste it wherever you want your table of contents to appear.
    • For example, you can paste at the bottom of each page, to make it easier to navigate your document.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment