1
0
mirror of https://github.com/bigchaindb/site.git synced 2024-11-22 01:36:55 +01:00

automatic table of contents for all guides

This commit is contained in:
Matthias Kretschmann 2017-11-17 12:21:07 +01:00
parent fb3b1d02b2
commit 10510a6850
Signed by: m
GPG Key ID: 606EEEF3C479A91F
9 changed files with 99 additions and 40 deletions

View File

@ -4,6 +4,7 @@ group :jekyll do
gem 'jekyll' gem 'jekyll'
gem 'jekyll-sitemap' gem 'jekyll-sitemap'
gem 'jekyll-redirect-from' gem 'jekyll-redirect-from'
gem 'jekyll-toc'
gem 'redcarpet' gem 'redcarpet'
end end

View File

@ -94,11 +94,19 @@ collections:
output: true output: true
permalink: /:collection/:path/ permalink: /:collection/:path/
defaults:
- scope:
path: ""
type: guides
values:
toc: true
# Plugins # Plugins
# -------------------- # --------------------
plugins: plugins:
- jekyll-sitemap - jekyll-sitemap
- jekyll-redirect-from - jekyll-redirect-from
- jekyll-toc
jekyll_get: jekyll_get:

View File

@ -23,7 +23,7 @@ jQuery(function($) {
// //
// init Smooth Scroll // init Smooth Scroll
// //
var scroll = new SmoothScroll('a[data-scroll]', { var scroll = new SmoothScroll('a[data-scroll], .toc-entry a', {
easing: 'easeOutQuint' easing: 'easeOutQuint'
}); });

View File

@ -65,3 +65,49 @@ h1.guide__title {
margin-top: 0; margin-top: 0;
color: $brand-primary; color: $brand-primary;
} }
//
// TOC
//
.section-nav {
background: darken($brand-main-gray, 2%);
margin-bottom: $spacer * 2;
padding: $spacer;
border-radius: $border-radius;
}
.toc-entry {
}
li.toc-h1 {
margin-bottom: $spacer / 2;
// custom numbers
&:before {
font-size: $font-size-h5;
opacity: .5;
}
a {
@extend .h5;
margin: 0;
box-shadow: none;
color: $brand-primary;
}
ul {
padding-left: $spacer * 3;
}
}
li.toc-h2 {
a {
font-size: $font-size-base;
color: $text-color;
}
}
li.toc-h3 {
display: none;
}

View File

@ -7,27 +7,27 @@
li { padding-left: 0; } li { padding-left: 0; }
&:before { &:before {
@extend .h1; @extend .h5;
content: 'Table Of Contents'; content: 'Contents';
display: block; display: block;
border-bottom: 1px solid $brand-main-blue-light; margin-top: 0;
padding-bottom: $spacer;
margin-bottom: ($spacer * 2);
text-align: center;
} }
li, li,
ol { margin: 0; } ol,
ul { margin: 0; }
li { li {
display: block; display: block;
}
> li {
// custom numbers // custom numbers
&:before { &:before {
content: counters(item, '.') ' '; content: counters(item, '.') '. ';
counter-increment: item; counter-increment: item;
margin-right: $spacer; margin-right: $spacer / 4;
color: $brand-main-gray; color: $brand-main-gray-light;
} }
} }
} }
@ -35,7 +35,8 @@
// output by Kramdown // output by Kramdown
/* stylelint-disable selector-no-id */ /* stylelint-disable selector-no-id */
#markdown-toc { #markdown-toc,
.section-nav {
@extend .toc; @extend .toc;
} }

View File

@ -0,0 +1,25 @@
<section class="section section--guides">
<div class="row">
<header class="section-header">
<h1 class="section-title">Guides</h1>
<p class="section-description">Complete these guides to learn about how to create apps in BigchainDB.</p>
</header>
</div>
<div class="row row--wide">
<div class="grid grid--full grid-small--half grid--gutters">
{% for guide in site.guides limit: 4 %}
<div class="grid__col">
<article class="guide">
<a href="{{ guide.url }}">
<h1 class="guide__title">{{ guide.title }}</h1>
<p class="guide__description">{{ guide.description }}</p>
</a>
</article>
</div>
{% endfor %}
</div>
</div>
<div class="row text-center">
<a class="btn btn-secondary" href="/guides/">All guides</a>
</div>
</section>

View File

@ -23,7 +23,7 @@ layout: base
</header> </header>
{% endif %} {% endif %}
{{ content }} {{ content | toc }}
</div> </div>
</section> </section>
@ -47,6 +47,6 @@ layout: base
</div> </div>
</div> </div>
<div class="row text-center"> <div class="row text-center">
<a href="/guides/">All guides</a> <a class="btn btn-secondary" href="/guides/">All guides</a>
</div> </div>
</section> </section>

View File

@ -2,6 +2,8 @@
layout: page layout: page
title: Guides title: Guides
js: page-guides.min.js
--- ---
<section class="section section--guides"> <section class="section section--guides">
@ -24,4 +26,4 @@ title: Guides
{% endfor %} {% endfor %}
</div> </div>
</div> </div>
</section> </section>

View File

@ -64,31 +64,7 @@ intro:
</div> </div>
</section> </section>
<section class="section section--guides"> {% include sections/section-guides.html %}
<div class="row">
<header class="section-header">
<h1 class="section-title">Guides</h1>
<p class="section-description">Complete these guides to learn about how to create apps in BigchainDB.</p>
</header>
</div>
<div class="row row--wide">
<div class="grid grid--full grid-small--half grid--gutters">
{% for guide in site.guides limit: 4 %}
<div class="grid__col">
<article class="guide">
<a href="{{ guide.url }}">
<h1 class="guide__title">{{ guide.title }}</h1>
<p class="guide__description">{{ guide.description }}</p>
</a>
</article>
</div>
{% endfor %}
</div>
</div>
<div class="row text-center">
<a class="btn btn-secondary" href="/guides/">All guides</a>
</div>
</section>
{% include sections/section-partners.html %} {% include sections/section-partners.html %}