Skip to content

Commit 418cf1d

Browse files
authored
Merge pull request just-the-docs#175 from pmarsceill/v0.2.6-release
v0.2.6 release
2 parents 14a3ff5 + 1342740 commit 418cf1d

29 files changed

+1186
-698
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<p align="right">
2-
<a href="https://badge.fury.io/rb/just-the-docs"><img src="https://badge.fury.io/rb/just-the-docs.svg" alt="Gem version"></a> <a href="https://travis-ci.com/pmarsceill/just-the-docs"><img src="https://travis-ci.com/pmarsceill/just-the-docs.svg?branch=master" alt="Build status"></a>
2+
<a href="https://badge.fury.io/rb/just-the-docs"><img src="https://badge.fury.io/rb/just-the-docs.svg" alt="Gem version"></a> <a href="https://github.com/pmarsceill/just-the-docs/actions"><img src="https://github.com/pmarsceill/just-the-docs/workflows/CI/badge.svg" alt="Build status"></a>
33
</p>
44
<br><br>
55
<p align="center">

_config.yml

+16-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# in the templates via {{ site.myvariable }}.
1616
title: Just the Docs
1717
description: A Jekyll theme for documentation
18-
baseurl: "/just-the-docs/" # the subpath of your site, e.g. /blog
18+
baseurl: "/just-the-docs" # the subpath of your site, e.g. /blog
1919
url: "https://pmarsceill.github.io" # the base hostname & protocol for your site, e.g. http://example.com
2020

2121
permalink: pretty
@@ -24,11 +24,17 @@ exclude: ["node_modules/", "*.gemspec", "*.gem", "Gemfile", "Gemfile.lock", "pac
2424
# Enable or disable the site search
2525
search_enabled: true
2626

27+
# Enable or disable heading anchors
28+
heading_anchors: true
29+
2730
# Aux links for the upper right navigation
2831
aux_links:
2932
"Just the Docs on GitHub":
3033
- "//github.com/pmarsceill/just-the-docs"
3134

35+
# Footer content appears at the bottom of every page's main content
36+
footer_content: "Copyright &copy; 2017-2019 Patrick Marsceill. Distributed by an <a href=\"https://github.com/pmarsceill/just-the-docs/tree/master/LICENSE.txt\">MIT license.</a>"
37+
3238
# Color scheme currently only supports "dark" or nil (default)
3339
color_scheme: nil
3440

@@ -37,4 +43,12 @@ color_scheme: nil
3743
ga_tracking: UA-2709176-10
3844

3945
plugins:
40-
- jekyll-seo-tag
46+
- jekyll-seo-tag
47+
48+
compress_html:
49+
clippings: all
50+
comments: all
51+
endings: all
52+
startings: []
53+
blank_lines: false
54+
profile: false

_includes/head.html

+17-11
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,35 @@
66
<title>{{ page.title }} - {{ site.title }}</title>
77

88
{% if page.description %}
9-
<meta name="Description" content="{{ page.description }}">
9+
<meta name="Description" content="{{ page.description }}">
1010
{% endif %}
1111
{% endif %}
1212

13-
<link rel="shortcut icon" href="{{ "favicon.ico" | absolute_url }}" type="image/x-icon">
13+
<link rel="shortcut icon" href="{{ 'favicon.ico' | absolute_url }}" type="image/x-icon">
1414

15-
<link rel="stylesheet" href="{{ "/assets/css/just-the-docs.css" | absolute_url }}">
15+
<link rel="stylesheet" href="{{ '/assets/css/just-the-docs.css' | absolute_url }}">
1616

1717
{% if site.ga_tracking != nil %}
18+
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.ga_tracking }}"></script>
1819
<script>
19-
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
20-
ga('create', '{{ site.ga_tracking }}', '{{ site.url }}');
21-
ga('send', 'pageview');
20+
window.dataLayer = window.dataLayer || [];
21+
function gtag(){dataLayer.push(arguments);}
22+
gtag('js', new Date());
23+
24+
gtag('config', "{{ site.ga_tracking }}");
2225
</script>
23-
<script async src="https://www.google-analytics.com/analytics.js"></script>
26+
2427
{% endif %}
2528

26-
{% if site.search_enabled != nil %}
27-
<script type="text/javascript" src="{{ "/assets/js/vendor/lunr.min.js" | absolute_url }}"></script>
29+
{% if site.search_enabled != false %}
30+
<script type="text/javascript" src="{{ '/assets/js/vendor/lunr.min.js' | absolute_url }}"></script>
2831
{% endif %}
29-
<script type="text/javascript" src="{{ "/assets/js/just-the-docs.js" | absolute_url }}"></script>
32+
<script type="text/javascript" src="{{ '/assets/js/just-the-docs.js' | absolute_url }}"></script>
3033

3134
<meta name="viewport" content="width=device-width, initial-scale=1">
3235

33-
{% seo %}
36+
{% seo %}
37+
38+
{% include head_custom.html %}
39+
3440
</head>

_includes/head_custom.html

Whitespace-only changes.

_includes/js/custom.js

Whitespace-only changes.

_includes/nav.html

+30-34
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,40 @@
11
<nav role="navigation" aria-label="Main navigation">
22
<ul class="navigation-list">
3-
{% assign pages_list = site.html_pages | sort:"nav_order" %}
4-
{% for node in pages_list %}
5-
{% unless node.nav_exclude %}
6-
{% if node.parent == nil %}
3+
{%- assign pages_list = site.html_pages | sort:"nav_order" -%}
4+
{%- for node in pages_list -%}
5+
{%- unless node.nav_exclude -%}
6+
{%- if node.parent == nil -%}
77
<li class="navigation-list-item{% if page.url == node.url or page.parent == node.title or page.grand_parent == node.title %} active{% endif %}">
8-
{% if page.parent == node.title or page.grand_parent == node.title %}
9-
{% assign first_level_url = node.url | absolute_url %}
10-
{% endif %}
8+
{%- if page.parent == node.title or page.grand_parent == node.title -%}
9+
{%- assign first_level_url = node.url | absolute_url -%}
10+
{%- endif -%}
1111
<a href="{{ node.url | absolute_url }}" class="navigation-list-link{% if page.url == node.url %} active{% endif %}">{{ node.title }}</a>
12-
{% if node.has_children %}
13-
{% assign children_list = site.html_pages | sort:"nav_order" %}
12+
{%- if node.has_children -%}
13+
{%- assign children_list = site.html_pages | where: "parent", node.title | sort:"nav_order" -%}
1414
<ul class="navigation-list-child-list ">
15-
{% for child in children_list %}
16-
{% if child.parent == node.title %}
17-
<li class="navigation-list-item {% if page.url == child.url or page.parent == child.title %} active{% endif %}">
18-
{% if page.url == child.url or page.parent == child.title %}
19-
{% assign second_level_url = child.url | absolute_url %}
20-
{% endif %}
21-
<a href="{{ child.url | absolute_url }}" class="navigation-list-link{% if page.url == child.url %} active{% endif %}">{{ child.title }}</a>
22-
{% if child.has_children %}
23-
{% assign grand_children_list = site.html_pages | sort:"nav_order" %}
15+
{%- for child in children_list -%}
16+
<li class="navigation-list-item {% if page.url == child.url or page.parent == child.title %} active{% endif %}">
17+
{%- if page.url == child.url or page.parent == child.title -%}
18+
{%- assign second_level_url = child.url | absolute_url -%}
19+
{%- endif -%}
20+
<a href="{{ child.url | absolute_url }}" class="navigation-list-link{% if page.url == child.url %} active{% endif %}">{{ child.title }}</a>
21+
{%- if child.has_children -%}
22+
{%- assign grand_children_list = site.html_pages | where: "parent", child.title | sort:"nav_order" -%}
2423
<ul class="navigation-list-child-list">
25-
{% for grand_child in grand_children_list %}
26-
{% if grand_child.parent == child.title %}
27-
<li class="navigation-list-item {% if page.url == grand_child.url %} active{% endif %}">
28-
<a href="{{ grand_child.url | absolute_url }}" class="navigation-list-link{% if page.url == grand_child.url %} active{% endif %}">{{ grand_child.title }}</a>
29-
</li>
30-
{% endif %}
31-
{% endfor %}
32-
</ul>
33-
{% endif %}
34-
</li>
35-
{% endif %}
36-
{% endfor %}
24+
{%- for grand_child in grand_children_list -%}
25+
<li class="navigation-list-item {% if page.url == grand_child.url %} active{% endif %}">
26+
<a href="{{ grand_child.url | absolute_url }}" class="navigation-list-link{% if page.url == grand_child.url %} active{% endif %}">{{ grand_child.title }}</a>
27+
</li>
28+
{%- endfor -%}
29+
</ul>
30+
{%- endif -%}
31+
</li>
32+
{%- endfor -%}
3733
</ul>
38-
{% endif %}
34+
{%- endif -%}
3935
</li>
40-
{% endif %}
41-
{% endunless %}
42-
{% endfor %}
36+
{%- endif -%}
37+
{%- endunless -%}
38+
{%- endfor -%}
4339
</ul>
4440
</nav>

_includes/title.html

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{ site.title }}

_includes/vendor/anchor_headings.html

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{% capture headingsWorkspace %}
2+
{% comment %}
3+
Version 1.0.3
4+
https://github.com/allejo/jekyll-anchor-headings
5+
6+
"Be the pull request you wish to see in the world." ~Ben Balter
7+
8+
Usage:
9+
{% include anchor_headings.html html=content %}
10+
11+
Parameters:
12+
* html (string) - the HTML of compiled markdown generated by kramdown in Jekyll
13+
14+
Optional Parameters:
15+
* beforeHeading (bool) : false - Set to true if the anchor should be placed _before_ the heading's content
16+
* anchorBody (string) : '' - The content that will be placed inside the anchor; the `%heading%` placeholder is available
17+
* anchorClass (string) : '' - The class(es) that will be used for each anchor. Separate multiple classes with a space
18+
* anchorTitle (string) : '' - The `title` attribute that will be used for anchors
19+
* h_min (int) : 1 - The minimum header level to build an anchor for; any header lower than this value will be ignored
20+
* h_max (int) : 6 - The maximum header level to build an anchor for; any header greater than this value will be ignored
21+
* bodyPrefix (string) : '' - Anything that should be inserted inside of the heading tag _before_ its anchor and content
22+
* bodySuffix (string) : '' - Anything that should be inserted inside of the heading tag _after_ its anchor and content
23+
24+
Output:
25+
The original HTML with the addition of anchors inside of all of the h1-h6 headings.
26+
{% endcomment %}
27+
28+
{% assign minHeader = include.h_min | default: 1 %}
29+
{% assign maxHeader = include.h_max | default: 6 %}
30+
{% assign beforeHeading = include.beforeHeading %}
31+
{% assign nodes = include.html | split: '<h' %}
32+
33+
{% capture edited_headings %}{% endcapture %}
34+
35+
{% for _node in nodes %}
36+
{% capture node %}{{ _node | strip }}{% endcapture %}
37+
38+
{% if node == "" %}
39+
{% continue %}
40+
{% endif %}
41+
42+
{% assign nextChar = node | replace: '"', '' | strip | slice: 0, 1 %}
43+
{% assign headerLevel = nextChar | times: 1 %}
44+
45+
<!-- If the level is cast to 0, it means it's not a h1-h6 tag, so let's try to fix it -->
46+
{% if headerLevel == 0 %}
47+
{% if nextChar != '<' and nextChar != '' %}
48+
{% capture node %}<h{{ node }}{% endcapture %}
49+
{% endif %}
50+
51+
{% capture edited_headings %}{{ edited_headings }}{{ node }}{% endcapture %}
52+
{% continue %}
53+
{% endif %}
54+
55+
{% assign _workspace = node | split: '</h' %}
56+
{% assign _idWorkspace = _workspace[0] | split: 'id="' %}
57+
{% assign _idWorkspace = _idWorkspace[1] | split: '"' %}
58+
{% assign html_id = _idWorkspace[0] %}
59+
60+
{% capture _hAttrToStrip %}{{ _workspace[0] | split: '>' | first }}>{% endcapture %}
61+
{% assign header = _workspace[0] | replace: _hAttrToStrip, '' %}
62+
63+
<!-- Build the anchor to inject for our heading -->
64+
{% capture anchor %}{% endcapture %}
65+
66+
{% if html_id and headerLevel >= minHeader and headerLevel <= maxHeader %}
67+
{% capture anchor %}href="#{{ html_id}}"{% endcapture %}
68+
69+
{% if include.anchorClass %}
70+
{% capture anchor %}{{ anchor }} class="{{ include.anchorClass }}"{% endcapture %}
71+
{% endif %}
72+
73+
{% if include.anchorTitle %}
74+
{% capture anchor %}{{ anchor }} title="{{ include.anchorTitle | replace: '%heading%', header }}"{% endcapture %}
75+
{% endif %}
76+
77+
{% capture anchor %}<a {{ anchor }}>{{ include.anchorBody | replace: '%heading%', header | default: '' }}</a>{% endcapture %}
78+
79+
<!-- In order to prevent adding extra space after a heading, we'll let the 'anchor' value contain it -->
80+
{% if beforeHeading %}
81+
{% capture anchor %}{{ anchor }} {% endcapture %}
82+
{% else %}
83+
{% capture anchor %} {{ anchor }}{% endcapture %}
84+
{% endif %}
85+
{% endif %}
86+
87+
{% capture new_heading %}
88+
<h{{ _hAttrToStrip }}
89+
{{ include.bodyPrefix }}
90+
{% if beforeHeading %}
91+
{{ anchor }}{{ header }}
92+
{% else %}
93+
{{ header }}{{ anchor }}
94+
{% endif %}
95+
{{ include.bodySuffix }}
96+
</h{{ _workspace | last }}
97+
{% endcapture %}
98+
{% capture edited_headings %}{{ edited_headings }}{{ new_heading }}{% endcapture %}
99+
{% endfor %}
100+
{% endcapture %}{% assign headingsWorkspace = '' %}{{ edited_headings | strip }}

0 commit comments

Comments
 (0)