From e4662876031aa98291bf99ed455edff3044d44ef Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Mon, 7 Aug 2017 14:42:03 -0500 Subject: [PATCH] Magic trick to remove title duplication in TOC --- _data/toc.yml | 18 ++++++++++++++++++ _includes/toc.md | 21 --------------------- _layouts/docs.html | 32 ++++++++++++++++++++++++++++++-- assets/css/index.scss | 12 ------------ 4 files changed, 48 insertions(+), 35 deletions(-) create mode 100644 _data/toc.yml delete mode 100644 _includes/toc.md diff --git a/_data/toc.yml b/_data/toc.yml new file mode 100644 index 0000000..46ed7e7 --- /dev/null +++ b/_data/toc.yml @@ -0,0 +1,18 @@ +Getting Started: + - docs/README.md + - docs/hello-world.md + - docs/development.md + - docs/webhooks.md + - docs/github-api.md +Advanced: + - docs/http.md + - docs/simulating-webhooks.md + - docs/testing.md + - docs/pagination.md + - docs/deployment.md + - docs/best-practices.md +Reference: + - title: robot + url: "https://probot.github.io/probot/latest/Robot.htm" + - title: context + url: "https://probot.github.io/probot/latest/Contex.html" diff --git a/_includes/toc.md b/_includes/toc.md deleted file mode 100644 index 6e72900..0000000 --- a/_includes/toc.md +++ /dev/null @@ -1,21 +0,0 @@ -#### Getting Started - -- [Introduction](/docs/) -- [Hello World](/docs/hello-world/) -- [Developing a plugin](/docs/development/) -- [Receiving webhooks](/docs/webhooks/) -- [Interacting with GitHub](/docs/github-api/) - -#### Advanced - -- [HTTP Routes](/docs/http/) -- [Simulating webhooks](/docs/simulating-webhooks/) -- [Testing](/docs/testing/) -- [Pagination](/docs/pagination/) -- [Deployment](/docs/deployment/) -- [Best Practices](/docs/best-practices/) - -#### Reference - -- [`robot`](https://probot.github.io/probot/latest/Robot.html) -- [`context`](https://probot.github.io/probot/latest/Context.html) diff --git a/_layouts/docs.html b/_layouts/docs.html index 9e8fab5..43ef3a0 100644 --- a/_layouts/docs.html +++ b/_layouts/docs.html @@ -7,8 +7,34 @@ layout: default
- {% capture toc %}{% include toc.md %}{% endcapture %} - {{ toc | markdownify }} + {% for section in site.data.toc %} +

{{ section[0] }}

+ +
    + {% for item in section[1] %} +
  • + {% if item.url %} + {% assign link = item %} + {% else %} + {% for doc in site.pages %} + {% if doc.path == item %} + {% assign link = doc %} + {% break %} + {% endif %} + {% endfor %} + {% endif %} + + {% if page.url == link.url %} + {% assign classes = "text-brand-red" %} + {% else %} + {% assign classes = "text-gray-light" %} + {% endif %} + + {{ link.title }} +
  • + {% endfor %} +
+ {% endfor %}
{{ content }} @@ -16,10 +42,12 @@ layout: default {% for doc in site.pages %} {% if page.next == doc.path %} {% assign next = doc %} + {% break %} {% endif %} {% if doc.next == page.path %} {% assign previous = doc %} + {% break %} {% endif %} {% endfor %} diff --git a/assets/css/index.scss b/assets/css/index.scss index b343dc9..f380348 100644 --- a/assets/css/index.scss +++ b/assets/css/index.scss @@ -26,15 +26,3 @@ img { code { font-size: 14px; } - -#toc { - h4 { - @extend .alt-h4, .text-gray; - margin-bottom: $spacer-2; - } - - ul { - margin-bottom: $spacer-4; - list-style: none; - } -}