Skip to content

Commit 547e88c

Browse files
committed
Added table of contents and ability to override the favicon
1 parent 42dcd22 commit 547e88c

File tree

12 files changed

+159
-13
lines changed

12 files changed

+159
-13
lines changed

README.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ This is a clean and simple Jekyll Theme built with the [Bulma](https://bulma.io/
1010
* [Installation](#installation)
1111
* [Usage](#usage)
1212
* [Pages](#pages)
13+
* [Page Hero](#page-hero)
14+
* [Table Of Contents](#table-of-contents)
1315
* [Posts](#posts)
1416
* [Navigation](#navigation)
1517
* [Colours and Styles](#colours-and-styles)
@@ -21,6 +23,7 @@ This is a clean and simple Jekyll Theme built with the [Bulma](https://bulma.io/
2123
* [Products](#products)
2224
* [Scripts](#scripts)
2325
* [Callouts](#callouts)
26+
* [Favicon](#favicon)
2427
* [Contributing](#contributing)
2528
* [Development](#development)
2629
* [Licence](#licence)
@@ -52,26 +55,33 @@ Or install it yourself as:
5255
5356
### Pages
5457
55-
Create your pages as individual markdown files and use the `layout: page` for normal pages. Set the pages title and subtitle in the frontmatter and it will appear in the hero.
58+
Create your pages as individual markdown files and use the `layout: page` for normal pages. Set the pages title and subtitle in the front matter and it will appear in the hero.
59+
60+
#### Page Hero
5661

5762
**New in 0.2**
58-
Heros can now display a background image if you provide a `hero_image: /path/to/image.jpg` setting in your page frontmatter, or in the [defaults](https://jekyllrb.com/docs/configuration/front-matter-defaults/) in your sites `_config.yml`
63+
Heros can now display a background image if you provide a `hero_image: /path/to/image.jpg` setting in your page front matter, or in the [defaults](https://jekyllrb.com/docs/configuration/front-matter-defaults/) in your sites `_config.yml`
5964

60-
You can also set the height of the hero by providing a bulma hero height class in your frontmatter, such as `hero_height: is-fullwidth`. If you do not provide this, it will revert to is-medium
65+
You can also set the height of the hero by providing a bulma hero height class in your front matter, such as `hero_height: is-fullwidth`. If you do not provide this, it will revert to is-medium
6166

6267
**New in 0.5.4**
63-
If you would like to add a call to action button in the hero then add `hero_link` and `hero_link_text` to the page's frontmatter.
68+
If you would like to add a call to action button in the hero then add `hero_link` and `hero_link_text` to the page's front matter.
6469

6570
**New in 0.5.7**
66-
If you would like to hide the hero, you can set `hide_hero: true` in the page's frontmatter.
71+
If you would like to hide the hero, you can set `hide_hero: true` in the page's front matter.
72+
73+
#### Table Of Contents
74+
75+
**New in 0.5.8**
76+
If you want to display a table of contents (toc) then add `toc: true` to your page's front matter. You can customise the default table of contents title by setting `toc_title: My Custom Title` in the page's front matter.
6777

6878
### Posts
6979

7080
If you want posts, create a `_posts` directory to store your posts as per normal Jekyll usage, with the `layout: post`. Next create a `blog` directory with an index.html file that has `layout: blog`
7181

72-
**New in 0.2** It will now display an image in the blog page if you set `image: /path/to/image.jpg` in your post's or page's frontmatter, or in the [defaults](https://jekyllrb.com/docs/configuration/front-matter-defaults/) in your sites `_config.yml`
82+
**New in 0.2** It will now display an image in the blog page if you set `image: /path/to/image.jpg` in your post's or page's front matter, or in the [defaults](https://jekyllrb.com/docs/configuration/front-matter-defaults/) in your sites `_config.yml`
7383

74-
You can also set the height of the hero by providing a bulma hero height class in your frontmatter, such as `hero_height: is-fullwidth`. If you do not provide this, it will revert to is-medium
84+
You can also set the height of the hero by providing a Bulma hero height class in your front matter, such as `hero_height: is-fullwidth`. If you do not provide this, it will revert to is-medium
7585

7686

7787
### Navigation
@@ -175,7 +185,7 @@ You may make multiple menus in the same file, separated by the label
175185

176186
**New in 0.4**
177187

178-
The tabs gets its content from a data file in your site's `_data` directory. Simply set the name of your data file in the page's menubar setting in the frontmatter.
188+
The tabs gets its content from a data file in your site's `_data` directory. Simply set the name of your data file in the page's menubar setting in the front matter.
179189

180190
```yaml
181191
title: Page with tabs
@@ -384,6 +394,10 @@ subtitle: This is an example landing page
384394
callouts: example_callouts
385395
```
386396

397+
### Favicon
398+
399+
The default favicon path is `{{ site.baseurl }}/favicon.png` but you can overwrite it in the sites `_config.yml` like this `favicon: /path/to/favicon.png`
400+
387401
## Contributing
388402

389403
Bug reports and pull requests are welcome on GitHub at https://github.com/chrisrhymes/bulma-clean-theme. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.

_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ description: >
77
baseurl: "/bulma-clean-theme"
88
url: "https://www.csrhymes.com"
99
permalink: pretty
10+
#favicon: /path/to/favicon.png
1011

1112
paginate: 5
1213
paginate_path: "/blog/page:num"

_data/example_menu.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
link: /page-5/
1818
- name: Page Without Hero
1919
link: /page-without-hero/
20+
- name: Page With Contents
21+
link: /page-with-contents/
2022
- name: Landing Page With Callouts
2123
link: /landing/
2224
- name: Blog

_data/navigation.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
link: /page-5/
1414
- name: Page Without Hero
1515
link: /page-without-hero/
16+
- name: Page With Contents
17+
link: /page-with-contents/
1618
- name: Landing Page With Callouts
1719
link: /landing/
1820
- name: Products

_includes/head.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
<meta name="viewport" content="width=device-width, initial-scale=1">
44
<title>{{ page.title }} - {{ site.title }}</title>
55
<link rel="stylesheet" href="{{ site.baseurl }}/assets/css/app.css">
6-
<link rel="shortcut icon" type="image/png" href="{{ site.baseurl }}/favicon.png" />
6+
<link rel="shortcut icon" type="image/png"
7+
{% if site.favicon %} href="{{ site.favicon | prepend: site.baseurl }}" {% else %} href="{{ site.baseurl }}/favicon.png" {% endif %}
8+
/>
79
<script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script>
810
{% seo %}
911
{%- if site.google_analytics -%}

_includes/toc.html

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{% capture tocWorkspace %}
2+
{% comment %}
3+
Version 1.0.8
4+
https://github.com/allejo/jekyll-toc
5+
{% endcomment %}
6+
7+
{% capture my_toc %}{% endcapture %}
8+
{% assign orderedList = include.ordered | default: false %}
9+
{% assign minHeader = include.h_min | default: 1 %}
10+
{% assign maxHeader = include.h_max | default: 6 %}
11+
{% assign nodes = include.html | split: '<h' %}
12+
{% assign firstHeader = true %}
13+
14+
{% capture listModifier %}{% if orderedList %}1.{% else %}-{% endif %}{% endcapture %}
15+
16+
{% for node in nodes %}
17+
{% if node == "" %}
18+
{% continue %}
19+
{% endif %}
20+
21+
{% assign headerLevel = node | replace: '"', '' | slice: 0, 1 | times: 1 %}
22+
23+
{% if headerLevel < minHeader or headerLevel > maxHeader %}
24+
{% continue %}
25+
{% endif %}
26+
27+
{% if firstHeader %}
28+
{% assign firstHeader = false %}
29+
{% assign minHeader = headerLevel %}
30+
{% endif %}
31+
32+
{% assign indentAmount = headerLevel | minus: minHeader %}
33+
{% assign _workspace = node | split: '</h' %}
34+
35+
{% assign _idWorkspace = _workspace[0] | split: 'id="' %}
36+
{% assign _idWorkspace = _idWorkspace[1] | split: '"' %}
37+
{% assign html_id = _idWorkspace[0] %}
38+
39+
{% assign _classWorkspace = _workspace[0] | split: 'class="' %}
40+
{% assign _classWorkspace = _classWorkspace[1] | split: '"' %}
41+
{% assign html_class = _classWorkspace[0] %}
42+
43+
{% if html_class contains "no_toc" %}
44+
{% continue %}
45+
{% endif %}
46+
47+
{% capture _hAttrToStrip %}{{ _workspace[0] | split: '>' | first }}>{% endcapture %}
48+
{% assign header = _workspace[0] | replace: _hAttrToStrip, '' %}
49+
50+
{% assign space = '' %}
51+
{% for i in (1..indentAmount) %}
52+
{% assign space = space | prepend: ' ' %}
53+
{% endfor %}
54+
55+
{% unless include.item_class == blank %}
56+
{% capture listItemClass %}{:.{{ include.item_class | replace: '%level%', headerLevel }}}{% endcapture %}
57+
{% endunless %}
58+
59+
{% capture heading_body %}{% if include.sanitize %}{{ header | strip_html }}{% else %}{{ header }}{% endif %}{% endcapture %}
60+
{% capture my_toc %}{{ my_toc }}
61+
{{ space }}{{ listModifier }} {{ listItemClass }} [{{ heading_body | replace: "|", "\|" }}]({% if include.baseurl %}{{ include.baseurl }}{% endif %}#{{ html_id }}){% if include.anchor_class %}{:.{{ include.anchor_class }}}{% endif %}{% endcapture %}
62+
{% endfor %}
63+
64+
{% if include.class %}
65+
{% capture my_toc %}{:.{{ include.class }}}
66+
{{ my_toc | lstrip }}{% endcapture %}
67+
{% endif %}
68+
69+
{% if include.id %}
70+
{% capture my_toc %}{: #{{ include.id }}}
71+
{{ my_toc | lstrip }}{% endcapture %}
72+
{% endif %}
73+
{% endcapture %}{% assign tocWorkspace = '' %}
74+
75+
<div class="contents">
76+
<div class="menu">
77+
<p class="menu-label">{{ include.contents_title }}</p>
78+
{{ my_toc | markdownify | strip }}
79+
</div>
80+
</div>
81+
82+

_layouts/page.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
layout: default
33
---
44

5+
{% if page.toc %}
6+
{% assign contentsTitle = page.toc_title | default: 'Contents' %}
7+
{% include toc.html html=content class='menu-list' h_min=2 h_max=3 contents_title=contentsTitle %}
8+
{% endif %}
59
<div class="content">
610
{{ content }}
711
</div>

_sass/_layout.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,9 @@ div.highlight {
2323
}
2424
}
2525
}
26+
27+
.contents {
28+
box-shadow: $box-shadow;
29+
padding: 1.5rem;
30+
margin-bottom: 3rem;
31+
}

_sass/_main.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ $tabs-link-active-border-bottom-color: $primary;
99

1010
@import "../node_modules/bulma/bulma.sass";
1111
@import "layout";
12-
@import "syntax"
12+
@import "syntax";

bulma-clean-theme.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
Gem::Specification.new do |spec|
44
spec.name = "bulma-clean-theme"
5-
spec.version = "0.5.7"
5+
spec.version = "0.5.8"
66
spec.authors = ["chrisrhymes"]
77
spec.email = ["[email protected]"]
88

9-
spec.summary = "Clean and simple theme using Bulma"
9+
spec.summary = "Clean and simple Jekyll theme built using Bulma"
1010
spec.homepage = "https://www.github.com/chrisrhymes/bulma-clean-theme"
1111
spec.license = "MIT"
1212

13-
spec.files = `git ls-files -z`.split("\x0").select { |f| f.match(%r!^(assets|_layouts|_includes|_sass|_posts|blog|LICENSE|README|package|node_modules|favicon.png|changelog.txt)!i) }
13+
spec.files = `git ls-files -z`.split("\x0").select { |f| f.match(%r!^(assets|_layouts|_includes|_sass|_posts|blog|LICENSE|README|package|node_modules|favicon)!i) }
1414

1515
spec.add_runtime_dependency "jekyll", "~> 3.8"
1616
spec.add_runtime_dependency "jekyll-feed", "~> 0.11"

0 commit comments

Comments
 (0)