Skip to content
This repository has been archived by the owner on Jun 19, 2020. It is now read-only.

Commit

Permalink
Updated all of the content, tweaked layout, and added new TOC generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Andrews committed Apr 27, 2020
1 parent ca9522b commit 9e2fd9f
Show file tree
Hide file tree
Showing 12 changed files with 316 additions and 122 deletions.
20 changes: 10 additions & 10 deletions docs/_data/nav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ sidebar:
- title: Node app projects
section: node
url: /app/node/
# subnav:
# - title: Getting started
# url: /app/node/getting_started.html
# - title: Command reference
# url: /app/node/commands.html
subnav:
- title: Getting started
url: /app/node/
- title: Command reference
url: /app/node/commands/
- title: Rails app projects
section: rails
url: /app/rails/
# subnav:
# - title: Getting started
# url: /app/rails/getting_started.html
# - title: Command reference
# url: /app/rails/commands.html
subnav:
- title: Getting started
url: /app/rails/
- title: Command reference
url: /app/rails/commands/
2 changes: 1 addition & 1 deletion docs/_includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property='st:title' content="{{ site.github.project_title }}">

<link rel="shortcut icon" href="https://cdn.shopify.com/assets/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" type="image/png" href="https://cdn.shopify.com/shopify-marketing_assets/static/shopify-favicon.png" />
<link href="https://cdn.shopify.com/shopify-marketing_assets/builds/88.3.2/marketing_assets.css" rel="stylesheet" type="text/css">
<link href="{{ site.url }}/css/docs.css" rel="stylesheet" type="text/css">
25 changes: 14 additions & 11 deletions docs/_includes/sidebar_nav.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
<ul class="in-page-menu in-page-menu--vertical">
{% for item in site.data.nav.sidebar %}
{% for item in site.data.nav.sidebar %}
<li>
<a class="{% if item.url == page.url %}is-active{% endif %}" href="{{ item.url }}">{{ item.title }}</a>

{% if item.section == page.section %}
<a class="{% if item.url == page.url %}is-active{% endif %}" href="{{ item.url }}">{{ item.title }}</a>
{% if item.section == page.section %}
<ul>
{% for subitem in item.subnav %}
{% for subitem in item.subnav %}
<li><a class="{% if subitem.url == page.url %}is-active{% endif %}" href="{{ subitem.url }}">{{ subitem.title }}</a></li>
{% endfor %}
{% endfor %}
</ul>
{% endif %}
{% endif %}
</li>
{% endfor %}
{% endfor %}
</ul>

<div>
<a href="{{ site.github.repository_url }}">GitHub repository</a>
</div>
<p>
<a href="{{ site.github.repository_url }}" class="link--external">GitHub repository</a>
</p>

<p>
<a href="https://shopify.dev/" class="link--external">Shopify Developer Docs</a><br />
</p>
112 changes: 112 additions & 0 deletions docs/_includes/toc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{% capture tocWorkspace %}
{% comment %}
Version 1.0.11
https://github.com/allejo/jekyll-toc

"...like all things liquid - where there's a will, and ~36 hours to spare, there's usually a/some way" ~jaybe

Usage:
{% include toc.html html=content sanitize=true class="inline_toc" id="my_toc" h_min=2 h_max=3 %}

Parameters:
* html (string) - the HTML of compiled markdown generated by kramdown in Jekyll

Optional Parameters:
* sanitize (bool) : false - when set to true, the headers will be stripped of any HTML in the TOC
* class (string) : '' - a CSS class assigned to the TOC
* id (string) : '' - an ID to assigned to the TOC
* h_min (int) : 1 - the minimum TOC header level to use; any header lower than this value will be ignored
* h_max (int) : 6 - the maximum TOC header level to use; any header greater than this value will be ignored
* ordered (bool) : false - when set to true, an ordered list will be outputted instead of an unordered list
* item_class (string) : '' - add custom class(es) for each list item; has support for '%level%' placeholder, which is the current heading level
* baseurl (string) : '' - add a base url to the TOC links for when your TOC is on another page than the actual content
* anchor_class (string) : '' - add custom class(es) for each anchor element
* skipNoIDs (bool) : false - skip headers that do not have an `id` attribute

Output:
An ordered or unordered list representing the table of contents of a markdown block. This snippet will only
generate the table of contents and will NOT output the markdown given to it
{% endcomment %}

{% capture my_toc %}{% endcapture %}
{% assign orderedList = include.ordered | default: false %}
{% assign skipNoIDs = include.skipNoIDs | default: false %}
{% assign minHeader = include.h_min | default: 1 %}
{% assign maxHeader = include.h_max | default: 6 %}
{% assign nodes = include.html | split: '<h' %}
{% assign firstHeader = true %}

{% capture listModifier %}{% if orderedList %}1.{% else %}-{% endif %}{% endcapture %}

{% for node in nodes %}
{% if node == "" %}
{% continue %}
{% endif %}

{% if skipNoIDs == true %}
{% unless node contains "id=" %}
{% continue %}
{% endunless %}
{% endif %}

{% assign headerLevel = node | replace: '"', '' | slice: 0, 1 | times: 1 %}

{% if headerLevel < minHeader or headerLevel > maxHeader %}
{% continue %}
{% endif %}

{% if firstHeader %}
{% assign firstHeader = false %}
{% assign minHeader = headerLevel %}
{% endif %}

{% assign indentAmount = headerLevel | minus: minHeader %}
{% assign _workspace = node | split: '</h' %}

{% assign _idWorkspace = _workspace[0] | split: 'id="' %}
{% assign _idWorkspace = _idWorkspace[1] | split: '"' %}
{% assign html_id = _idWorkspace[0] %}

{% assign _classWorkspace = _workspace[0] | split: 'class="' %}
{% assign _classWorkspace = _classWorkspace[1] | split: '"' %}
{% assign html_class = _classWorkspace[0] %}

{% if html_class contains "no_toc" %}
{% continue %}
{% endif %}

{% capture _hAttrToStrip %}{{ _workspace[0] | split: '>' | first }}>{% endcapture %}
{% assign header = _workspace[0] | replace: _hAttrToStrip, '' %}

{% assign space = '' %}
{% for i in (1..indentAmount) %}
{% assign space = space | prepend: ' ' %}
{% endfor %}

{% if include.item_class and include.item_class != blank %}
{% capture listItemClass %}{:.{{ include.item_class | replace: '%level%', headerLevel }}}{% endcapture %}
{% endif %}

{% capture anchor_body %}{% if include.sanitize %}{{ header | strip_html }}{% else %}{{ header }}{% endif %}{% endcapture %}
{% capture anchor_body %}{{ anchor_body | replace: "|", "\|" }}{% endcapture %}

{% if html_id %}
{% capture list_item %}[{{ anchor_body }}]({% if include.baseurl %}{{ include.baseurl }}{% endif %}#{{ html_id }}){% endcapture %}
{% else %}
{% capture list_item %}{{ anchor_body }}{% endcapture %}
{% endif %}

{% capture my_toc %}{{ my_toc }}
{{ space }}{{ listModifier }} {{ listItemClass }} {{ list_item }}{% if include.anchor_class %}{:.{{ include.anchor_class }}}{% endif %}{% endcapture %}
{% endfor %}

{% if include.class and include.class != blank %}
{% capture my_toc %}{:.{{ include.class }}}
{{ my_toc | lstrip }}{% endcapture %}
{% endif %}

{% if include.id %}
{% capture my_toc %}{: #{{ include.id }}}
{{ my_toc | lstrip }}{% endcapture %}
{% endif %}
{% endcapture %}{% assign tocWorkspace = '' %}{{ my_toc | markdownify | strip }}
Loading

0 comments on commit 9e2fd9f

Please sign in to comment.