toshimaru / jekyll-toc Goto Github PK
View Code? Open in Web Editor NEWJekyll plugin which generates a table of contents.
License: MIT License
Jekyll plugin which generates a table of contents.
License: MIT License
In our use case we never want the following to be included in the TOC:
<h2>foo</h2>
<h3>bar</h3>
<div class="bd-example">
<p>text</p>
<h4>header</h4> <!-- we need to ignore this -->
</div>
<h3>bar</h3>
Updating from jekyll-toc 0.4.0 to 13.1.0, I found the following issue: id attribute missing in all <a>
tags inside <h>
tags
generated by 0.4.0
<h2><a id="historique-du-site-depuis-1970" class="anchor" href="#historique-du-site-depuis-1970" aria-hidden="true"><span class="octicon octicon-link"></span></a>Historique du site depuis 1970</h2>
generated by 13.1.0
<h2><a class="anchor" href="#historique-du-site-depuis-1970" aria-hidden="true"><span class="octicon octicon-link"></span></a>Historique du site depuis 1970</h2>
How to solve this issue ?
So I'm trying to fix an issue where sticky headers overlap/cover headings when navigating using the ToC.
Would an option, when using the inject_anchors
option, to move the id from the containing header into the injected anchor be possible?
Hello,
The new tag scheme disturbs the layout of my site since I have TOC content in asides for contents other that posts and collections in my sites. Could you please advise me some workaround for this? Apart from this, thanks for jekyll-toc, Toshimaru, this is a very handy addition!
Frédéric Salard-Deschandol, from Nice, France
Thinking it might be useful to set a config (likely managed at _config.yml
) around only outputting the ToC when there are two or more items that would be output. It seems the best way to manage that today is disabling the ToC on those specific pages and enabling it once ya have more headers used.
The plugin works fine locally, but when I push the website to the GitHub pages, it doesn't work there. Is there any way to make it work on GitHub beside producing a static version of the website in gh-pages
branch and pushing that to the GitHub?
Thanks a lot. :-)
Cheers,
Vahid
Please see sample project
https://github.com/pavelsr/jekyll-toc-test
jekyll-toc generates just toc from index.html
and not considering site.sections
<ul class="section-nav">
<li class="toc-entry toc-h1"><a href="#coding-standarts">Coding standarts</a></li>
</ul>
{% toc %}
currently only renders the TOC based off of the {{ content }}
var. I've run into scenarios where I needed to template in additional headings and metadata-generated content before or after the content as boilerplate HTML, that would still be nice to have in a table of contents. I'm supposing it might look like:
{%- capture key_concepts_heading -%}<h2>Key Concepts</h2>{% endcapture -%}
{%- capture license_heading -%}<h2>License</h2>{% endcapture -%}
{% toc | prepend: key_concepts_heading | append: license_heading %}
...
{{ key_concepts_heading }}
{{ page.key_concepts }}
{{ content }}
{{ license_heading }}
{{ page.license }}
I did the walkthrough according to the README
Here is the site: https://joelouthan.github.io/ownCloud/
Here is the repo: https://github.com/joelouthan/ownCloud/tree/master/docs
This is for the default.md in which index.md is using layout: default.
Within my _layouts/default.html
<section> <h1>{{ page.title }}</h1> {{ content | toc }} </section>
And in my index.md, I am using h2.
But it still does not render the toc locally nor on github.
Any thoughts?
Create catchy og image.
For some reason, when the toc was included, the footnote anchor links were not working on any browser.
.section-nav:before{
font-size: 20px;
content: "Table Of Contents : ";
line-height: 3;
font-weight: bold;}
Thanks...
When using your step-by-step guide and then try to use the plugin, nothing happens.
I'm not sure if it's the install there never do anything or if it the plugin there is outdated or even if it because I try to use it on a page instead of post.
When I install it nothing happens in the files, is this right? only see a lot of things happens in the Terminal
In _config.yml I have the following setting that ensures that only h2 elements show up in the automatically generated table of contents.
toc:
min_level: 2 # default: 1
max_level: 2 # default: 6
This works fine, but on some pages, I would like to include h3 elements in the toc as well. So I want to change the max_level to 3 in a particular case. Is this possible? I want to change max_level value dynamically from the template code. Please help
is it possible to limit the depth of the TOC ? l
{% if post.toc %}
{{ post.content | toc }}
{% else %}
{{ post.content }}
{% endif %}
Easy to use javascript plugin ..
Switch from filter to tag.
def toc(html)
> page.content == html
=> true
{:toc}
http://www.seanbuscay.com/blog/jekyll-toc-markdown/I've never used octicons before, so some help in the readme would be useful.
Thanks and great work!
Using v0.3.0, I'm trying to generate a toc from h2 and h3 entries. When I try, I get an empty <ul>
element in the place where the h3 entries should be found. For example:
<ul class="section-nav nav" style="opacity: 1;">
<li class="toc-entry toc-h2"><a href="#what-are-structural-directives">What are structural directives?</a></li>
<li class="toc-entry toc-h2"><a href="#ngif-case-study">NgIf case study</a>
<ul>
</ul>
</li>
...
Notice the empty nested <ul>
. My CSS is like this:
.toc-entry.toc-h2,
.toc-entry.toc-h3 {}
.toc-entry.toc-h1,
.toc-entry.toc-h4,
.toc-entry.toc-h5,
.toc-entry.toc-h6,
.no_toc {
display: none;
}
cc @kwalrath
Hi;
The plugin is working pretty fine in the basic mode, but I couldn't make it work in the advanced mode using toc_only
and inject_anchors
filters. I probably have missed something. Could you please guide me how to use it in a custom location in a layout/page?
Thanks in advance.
Vahid
Hi, could you please let me know how to resolve this issue
The tag toc on line 59 in /_layouts/post.html is not a recognized Liquid tag.
my _config.yml
# Plugins
plugins:
- jekyll-feed
- jekyll-sitemap
- jekyll-paginate
- jekyll-seo-tag
- jemoji
- jekyll-toc
I have in my TOC the German word "Datenschutzerklärung" (engl. Privacy) with an ä inside.
When I create the TOC the href or the anchor are getting #datenschutzerkl%C3%A4rung
<a class="anchor" href="#datenschutzerkl%C3%A4rung" aria-hidden="true"><span class="octicon octicon-link"></span></a>
In the url bar of my browser I see https://example.com/#datenschutzerklärung.
To harmonize the results and be secure for other special chars, I would suggest to use url_encode for the ID-Element and the Anchor-Link.
When I develop locally with bundle exec jekyll serve
, everything works like it should. When I push my changes to GitHub, however, there's no TOC in my posts.
imject-anchors is injectiong invalid html with duplicate IDs.
the code heading one
generates
<h1 id="header-one">↩
<a id="header-one" class="anchor" href="#header-one" aria-hidden="true"><span class="octicon octicon-link"></span></a>Header one</h1>↩
and that is invalid HTML as it contains duplicate IDs. This is poor practice and may cause errors in some browsers.
Hi.
So I tried the new version with our Bootstrap docs with version 0.7.1 and it doesn't seem to work...
toc:
ignore_within: ".bd-example"
min_level: 2
max_level: 4
<div class="bd-example">
<div class="alert alert-success" role="alert">
<h4 class="alert-heading">Well done!</h4>
<p>Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so that you can see how spacing within an alert works with this kind of content.</p>
<hr>
<p class="mb-0">Whenever you need to, be sure to use margin utilities to keep things nice and tidy.</p>
</div>
</div>
I also tried bd-example
which doesn't seem to work either. I'm still getting Well done!
in ToC.
PR: twbs/bootstrap#27417
Live preview: https://deploy-preview-27417--twbs-bootstrap4.netlify.com/docs/4.1/components/alerts/
It would be great if one could set custom class names to replace section-nav
& toc-entry
, as well as a custom prefix to replace toc-h
. This would allow integrating it into existing sites easily, re-using existing CSS classes.
I'm thinking something like the following set in the _config.yml
:
toc:
list_class: list
item_class: item
item_prefix: level_
Resulting in:
<ul class="list">
<li class="item level_1"><a href="#heading1">Heading.1</a></li>
<li class="item level_2"><a href="#heading2-1">Heading.2-1</a></li>
</ul>
I'm happy to submit a pull request if this is within scope.
If there' no big performance hit, this would make the plugin way more extensible and will cover more use cases.
Hi! Thanks for the plugin! How is it possible to enable this by default for all pages? Here's a PR where I'm trying to enable this for some pages https://github.com/home-assistant/home-assistant.io/pull/13572/files.
In short:
{% toc %}
since this is applied in an aside.toc: true
is defined in the _config.yaml
defaults .Still, the ToC doesn't appear. If I set it explicitly in a page's frontmatter, it works, but I want to avoid that though since there are 1000+ pages this should be applied to.
Any help would be appreciated, thanks!
Hi;
I have a website with Jekyll 3.5.2 and it seems this plugin is not working on that, not in pages, nor in layouts.
Thanks,
Vahid
Current:
AllCops:
TargetRubyVersion: 2.4
Exclude:
- "*.gemspec"
- "gemfiles/*"
- Rakefile
- Gemfile
Should be:
AllCops:
TargetRubyVersion: 2.4
Exclude:
- "*.gemspec"
- "gemfiles/*"
- gems/**/*
- node_modules/**/*
- vendor/bundle/**/*
- Rakefile
- Gemfile
I think it would be great to give user an opportunity to customize injected anchors, for example by adding toc-injected-anchors.html template to _includes directory, the content of which will override default string.
The toc
(<ul></ul>
) is not clickable. The h-elements (h1
, h2
, h3
...) do not have the correct id or the id is missing at all.
When clicking a header, sometimes it would render the content of the post a second time.
Hi
I am new to Jekyll blogging, I don't wat add toc on top of the page, instead of after some line of text in a post I want to add toc, could you please let me know how to do this?
It would be awesome, the toc
filter only prints out the TOC and not the content again.
In my scenario, I'd like to have the content not right below the TOC but the TOC being in a separate container, e.g. an aside.
Please add this option. Love the plugin!
For example, see https://webdev.dartlang.org/angular/tutorial/toh-pt5#base-href. Notice that TOC on the right (visible when your page is wide enough) doesn't contain an entry for "<base href>". Removing the < makes the TOC entry appear.
cc @kwalrath
For example
#### Dealing with specificity
Sometimes contextual classes cannot be applied due to the specificity of another selector. In some cases, a sufficient workaround is to wrap your element's content in a `<div>` with the class.
results in this being included in ToC
Demo: https://twbs-bootstrap4.netlify.com/docs/4.1/utilities/colors/
If I change the header to an h5, since we have max h4, then the header is not included in ToC.
/CC @toshimaru
It seems currently there's no way to change the ul.section-nav
. Adding an ID/class would make this a lot more flexible.
I was wondering if there is an easy way of adding a title to the table of contents.
Thanks,
Vahid
Hey, there.
So, in Bootstrap v4-dev we switched to your plugin.
I notice that the generated HTML is invalid.
See for example https://github.com/twbs/bootstrap/blob/v4-dev/docs/4.0/about/brand.md
The HTML we get is the following, which is invalid:
<ul class="section-nav">
<ul>
<li class="toc-entry toc-h2"><a href="#contents">Contents</a></li>
<li class="toc-entry toc-h2"><a href="#mark-and-logo">Mark and logo</a></li>
</ul>
<li class="toc-entry toc-h1"><a href="#bootstrap">Bootstrap</a></li>
<li class="toc-entry toc-h1"><a href="#bootstrap-1">Bootstrap</a>
<ul>
<li class="toc-entry toc-h2"><a href="#download-mark">Download mark</a></li>
<li class="toc-entry toc-h2"><a href="#name">Name</a>
<ul>
<li class="toc-entry toc-h3"><a href="#bootstrap-2">Bootstrap</a></li>
<li class="toc-entry toc-h3"><a href="#bootstrap-3">BootStrap</a></li>
<li class="toc-entry toc-h3"><a href="#twitter-bootstrap">Twitter Bootstrap</a></li>
</ul>
</li>
<li class="toc-entry toc-h2"><a href="#colors">Colors</a></li>
</ul>
</li>
</ul>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.