Skip to content

Commit

Permalink
improving section numbering and adding front page redirecting behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
choldgraf committed Jan 18, 2019
1 parent 471359f commit 6016d95
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 11 deletions.
2 changes: 0 additions & 2 deletions _build/intro.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
---
redirect_from:
- "/"
title: 'Home'
prev_page:
url:
Expand Down
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ collapse_inactive_chapters: true # Whether to collapse the inactive chapters in
textbook_logo : images/logo/logo.png # A logo to be displayed at the top of your textbook sidebar
textbook_logo_link : https://jupyter.org/jupyter-book/intro.html # A link for the logo.
sidebar_footer_text : 'Powered by <a href="https://github.com/jupyter/jupyter-book">Jupyter Book</a>'
number_toc_chapters : true # Whether to add numbers to chapterse in your Table of Contents. If true, you can control this at the Chapter level in _data/toc.yml

# Search settings
search_max_words_in_content : 100 # In the search function, use at most this many words (too many words will make search slow)
Expand Down
9 changes: 5 additions & 4 deletions _includes/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ <h2 class="c-sidebar__title">{{ site.title }}</h2>
{% else %}
{% assign active_class = "" %}
{% endif %}

{% assign topUrl = chapter.url | relative_url %}
{% unless chapter.external == true %}
{% assign topUrl = topUrl | append: '.html' %}
{% assign topUrl = topUrl | append: '.html' %}
{% endunless %}
<li class="c-sidebar__chapter">
<a class="c-sidebar__entry {{ active_class }}"
href="{{ topUrl }}"
>
{% unless chapter.not_numbered %}
{% unless chapter.not_numbered or site.number_toc_chapters != true %}
{{ chapter_num }}.
{% endunless %}
{{ chapter.title }}
Expand Down Expand Up @@ -101,7 +102,7 @@ <h2 class="c-sidebar__title">{{ site.title }}</h2>
<a class="c-sidebar__entry {{ active_class }}"
href="{{ section.url | relative_url | append: '.html'}}"
>
{% unless chapter.not_numbered or section.not_numbered %}
{% unless chapter.not_numbered or section.not_numbered or site.number_toc_chapters != true %} %}
{{ chapter_num }}.{{ section_num }}
{% endunless %}
{{ section.title }}
Expand All @@ -122,7 +123,7 @@ <h2 class="c-sidebar__title">{{ site.title }}</h2>
<a class="c-sidebar__entry {{ active_class }}"
href="{{ subsection.url | relative_url | append: '.html'}}"
>
{% unless chapter.not_numbered or section.not_numbered or subsection.not_numbered %}
{% unless chapter.not_numbered or section.not_numbered or subsection.not_numbered or site.number_toc_chapters != true %}
{{ chapter_num }}.{{ section_num }}.{{ subsection_num }}
{% assign subsection_num = subsection_num | plus: 1 %}
{% endunless %}
Expand Down
2 changes: 1 addition & 1 deletion assets/custom/custom.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Put your custom CSS here */
.left {
margin-left: 0px;
}
}
19 changes: 19 additions & 0 deletions assets/html/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
permalink: /index.html
title: "Index"
layout: none
---

<!-- The index page should simply re-direct to the first chapter -->
{% assign redirectURL=site.data.toc[0].url | relative_url %}
<!DOCTYPE html>
<html lang="en-US">
<meta charset="utf-8">
<title>Redirecting&hellip;</title>
<link rel="canonical" href="{{ redirectURL }}">
<script>location="{{ redirectURL }}"</script>
<meta http-equiv="refresh" content="0; url={{ redirectURL }}">
<meta name="robots" content="noindex">
<h1>Redirecting&hellip;</h1>
<a href="{{ redirectURL }}">Click here if you are not redirected.</a>
</html>
4 changes: 0 additions & 4 deletions scripts/generate_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,6 @@ def _case_sensitive_fs(path):
'sensitive FS, e.g. case-sensitive disk image on Mac')
yaml_fm += ['redirect_from:']
yaml_fm += [' - "{}"'.format(sanitized)]
if ix_file == 0:
if not sanitized != url_page:
yaml_fm += ['redirect_from:']
yaml_fm += [' - "/"']
if path_url_page.endswith('.ipynb'):
interact_path = 'content/' + path_url_page.split('content/')[-1]
yaml_fm += ['interact_link: {}'.format(interact_path)]
Expand Down

0 comments on commit 6016d95

Please sign in to comment.