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

Commit 9e2fd9f

Browse files
author
Luke Andrews
committed
Updated all of the content, tweaked layout, and added new TOC generator
1 parent ca9522b commit 9e2fd9f

File tree

12 files changed

+316
-122
lines changed

12 files changed

+316
-122
lines changed

docs/_data/nav.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ sidebar:
1111
- title: Node app projects
1212
section: node
1313
url: /app/node/
14-
# subnav:
15-
# - title: Getting started
16-
# url: /app/node/getting_started.html
17-
# - title: Command reference
18-
# url: /app/node/commands.html
14+
subnav:
15+
- title: Getting started
16+
url: /app/node/
17+
- title: Command reference
18+
url: /app/node/commands/
1919
- title: Rails app projects
2020
section: rails
2121
url: /app/rails/
22-
# subnav:
23-
# - title: Getting started
24-
# url: /app/rails/getting_started.html
25-
# - title: Command reference
26-
# url: /app/rails/commands.html
22+
subnav:
23+
- title: Getting started
24+
url: /app/rails/
25+
- title: Command reference
26+
url: /app/rails/commands/

docs/_includes/head.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
<meta name="viewport" content="width=device-width, initial-scale=1">
1515
<meta property='st:title' content="{{ site.github.project_title }}">
1616

17-
<link rel="shortcut icon" href="https://cdn.shopify.com/assets/favicon.ico" type="image/x-icon">
17+
<link rel="shortcut icon" type="image/png" href="https://cdn.shopify.com/shopify-marketing_assets/static/shopify-favicon.png" />
1818
<link href="https://cdn.shopify.com/shopify-marketing_assets/builds/88.3.2/marketing_assets.css" rel="stylesheet" type="text/css">
1919
<link href="{{ site.url }}/css/docs.css" rel="stylesheet" type="text/css">

docs/_includes/sidebar_nav.html

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
<ul class="in-page-menu in-page-menu--vertical">
2-
{% for item in site.data.nav.sidebar %}
2+
{% for item in site.data.nav.sidebar %}
33
<li>
4-
<a class="{% if item.url == page.url %}is-active{% endif %}" href="{{ item.url }}">{{ item.title }}</a>
5-
6-
{% if item.section == page.section %}
4+
<a class="{% if item.url == page.url %}is-active{% endif %}" href="{{ item.url }}">{{ item.title }}</a>
5+
{% if item.section == page.section %}
76
<ul>
8-
{% for subitem in item.subnav %}
7+
{% for subitem in item.subnav %}
98
<li><a class="{% if subitem.url == page.url %}is-active{% endif %}" href="{{ subitem.url }}">{{ subitem.title }}</a></li>
10-
{% endfor %}
9+
{% endfor %}
1110
</ul>
12-
{% endif %}
11+
{% endif %}
1312
</li>
14-
{% endfor %}
13+
{% endfor %}
1514
</ul>
1615

17-
<div>
18-
<a href="{{ site.github.repository_url }}">GitHub repository</a>
19-
</div>
16+
<p>
17+
<a href="{{ site.github.repository_url }}" class="link--external">GitHub repository</a>
18+
</p>
19+
20+
<p>
21+
<a href="https://shopify.dev/" class="link--external">Shopify Developer Docs</a><br />
22+
</p>

docs/_includes/toc.html

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
{% capture tocWorkspace %}
2+
{% comment %}
3+
Version 1.0.11
4+
https://github.com/allejo/jekyll-toc
5+
6+
"...like all things liquid - where there's a will, and ~36 hours to spare, there's usually a/some way" ~jaybe
7+
8+
Usage:
9+
{% include toc.html html=content sanitize=true class="inline_toc" id="my_toc" h_min=2 h_max=3 %}
10+
11+
Parameters:
12+
* html (string) - the HTML of compiled markdown generated by kramdown in Jekyll
13+
14+
Optional Parameters:
15+
* sanitize (bool) : false - when set to true, the headers will be stripped of any HTML in the TOC
16+
* class (string) : '' - a CSS class assigned to the TOC
17+
* id (string) : '' - an ID to assigned to the TOC
18+
* h_min (int) : 1 - the minimum TOC header level to use; any header lower than this value will be ignored
19+
* h_max (int) : 6 - the maximum TOC header level to use; any header greater than this value will be ignored
20+
* ordered (bool) : false - when set to true, an ordered list will be outputted instead of an unordered list
21+
* item_class (string) : '' - add custom class(es) for each list item; has support for '%level%' placeholder, which is the current heading level
22+
* baseurl (string) : '' - add a base url to the TOC links for when your TOC is on another page than the actual content
23+
* anchor_class (string) : '' - add custom class(es) for each anchor element
24+
* skipNoIDs (bool) : false - skip headers that do not have an `id` attribute
25+
26+
Output:
27+
An ordered or unordered list representing the table of contents of a markdown block. This snippet will only
28+
generate the table of contents and will NOT output the markdown given to it
29+
{% endcomment %}
30+
31+
{% capture my_toc %}{% endcapture %}
32+
{% assign orderedList = include.ordered | default: false %}
33+
{% assign skipNoIDs = include.skipNoIDs | default: false %}
34+
{% assign minHeader = include.h_min | default: 1 %}
35+
{% assign maxHeader = include.h_max | default: 6 %}
36+
{% assign nodes = include.html | split: '<h' %}
37+
{% assign firstHeader = true %}
38+
39+
{% capture listModifier %}{% if orderedList %}1.{% else %}-{% endif %}{% endcapture %}
40+
41+
{% for node in nodes %}
42+
{% if node == "" %}
43+
{% continue %}
44+
{% endif %}
45+
46+
{% if skipNoIDs == true %}
47+
{% unless node contains "id=" %}
48+
{% continue %}
49+
{% endunless %}
50+
{% endif %}
51+
52+
{% assign headerLevel = node | replace: '"', '' | slice: 0, 1 | times: 1 %}
53+
54+
{% if headerLevel < minHeader or headerLevel > maxHeader %}
55+
{% continue %}
56+
{% endif %}
57+
58+
{% if firstHeader %}
59+
{% assign firstHeader = false %}
60+
{% assign minHeader = headerLevel %}
61+
{% endif %}
62+
63+
{% assign indentAmount = headerLevel | minus: minHeader %}
64+
{% assign _workspace = node | split: '</h' %}
65+
66+
{% assign _idWorkspace = _workspace[0] | split: 'id="' %}
67+
{% assign _idWorkspace = _idWorkspace[1] | split: '"' %}
68+
{% assign html_id = _idWorkspace[0] %}
69+
70+
{% assign _classWorkspace = _workspace[0] | split: 'class="' %}
71+
{% assign _classWorkspace = _classWorkspace[1] | split: '"' %}
72+
{% assign html_class = _classWorkspace[0] %}
73+
74+
{% if html_class contains "no_toc" %}
75+
{% continue %}
76+
{% endif %}
77+
78+
{% capture _hAttrToStrip %}{{ _workspace[0] | split: '>' | first }}>{% endcapture %}
79+
{% assign header = _workspace[0] | replace: _hAttrToStrip, '' %}
80+
81+
{% assign space = '' %}
82+
{% for i in (1..indentAmount) %}
83+
{% assign space = space | prepend: ' ' %}
84+
{% endfor %}
85+
86+
{% if include.item_class and include.item_class != blank %}
87+
{% capture listItemClass %}{:.{{ include.item_class | replace: '%level%', headerLevel }}}{% endcapture %}
88+
{% endif %}
89+
90+
{% capture anchor_body %}{% if include.sanitize %}{{ header | strip_html }}{% else %}{{ header }}{% endif %}{% endcapture %}
91+
{% capture anchor_body %}{{ anchor_body | replace: "|", "\|" }}{% endcapture %}
92+
93+
{% if html_id %}
94+
{% capture list_item %}[{{ anchor_body }}]({% if include.baseurl %}{{ include.baseurl }}{% endif %}#{{ html_id }}){% endcapture %}
95+
{% else %}
96+
{% capture list_item %}{{ anchor_body }}{% endcapture %}
97+
{% endif %}
98+
99+
{% capture my_toc %}{{ my_toc }}
100+
{{ space }}{{ listModifier }} {{ listItemClass }} {{ list_item }}{% if include.anchor_class %}{:.{{ include.anchor_class }}}{% endif %}{% endcapture %}
101+
{% endfor %}
102+
103+
{% if include.class and include.class != blank %}
104+
{% capture my_toc %}{:.{{ include.class }}}
105+
{{ my_toc | lstrip }}{% endcapture %}
106+
{% endif %}
107+
108+
{% if include.id %}
109+
{% capture my_toc %}{: #{{ include.id }}}
110+
{{ my_toc | lstrip }}{% endcapture %}
111+
{% endif %}
112+
{% endcapture %}{% assign tocWorkspace = '' %}{{ my_toc | markdownify | strip }}

0 commit comments

Comments
 (0)