Skip to content

Commit 389efc6

Browse files
committed
refactor docs into include, create table of contents
1 parent 01e1dfe commit 389efc6

23 files changed

+90
-62
lines changed

_includes/doc.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<br />
2+
<br />
3+
<section id="{{ include.link }}">
4+
<!-- edit -->
5+
<a class="button edit-docs" href="//github.com/coderoad/coderoad.github.io/edit/master/_posts/{{ include.editPath }}/{{ include.file }}">
6+
<i class="fa fa-pencil fa-fw"></i>
7+
<span class="network-name">Edit</span>
8+
</a>
9+
<!-- content -->
10+
<h2>{{ include.index}}. {{ include.title }}</h2>
11+
<div>{{ include.content }}</div>
12+
</section>

_includes/docs.html

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
1-
<br />
2-
<br />
3-
<section id="{{ include.id }}">
4-
<a class="button edit-docs" href="{{ include.editPath }}/{{ include.file }}">
5-
<i class="fa fa-pencil fa-fw"></i>
6-
<span class="network-name">Edit</span>
7-
</a>
8-
<h2>{{ include.title }}</h2>
9-
<div>{{ include.content }}</div>
1+
<section id="docs">
2+
3+
<div class="doc-contents">
4+
<h2>Contents</h2>
5+
{% for doc in site.categories[include.category] reversed %}
6+
{% include table-of-contents.html
7+
link=doc.link
8+
title=doc.title
9+
index=forloop.index
10+
%}
11+
{% endfor %}
12+
</div>
13+
14+
<hr />
15+
16+
<!-- Docs -->
17+
<div>
18+
{% for doc in site.categories[include.category] reversed %}
19+
{% include doc.html
20+
link=doc.link
21+
title=doc.title
22+
content=doc.content
23+
editPath=include.category
24+
file=doc.file
25+
index=forloop.index
26+
%}
27+
{% endfor %}
28+
</div>
29+
1030
</section>

_includes/table-of-contents.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<a href="#{{ include.link }}">
2+
<h5>{{include.index}}. {{ include.title }}</h5>
3+
</a>

_posts/atom-coderoad/2016-01-01-explanation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: What is Atom-CodeRoad?
3-
id: explanation
3+
link: explanation
44
file: 2016-01-01-explanation.md
55
categories:
66
- atom-coderoad

_posts/atom-coderoad/2016-01-02-installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Quick Start
3-
id: install
3+
link: install
44
file: 2016-01-02-installation.md
55
categories:
66
- atom-coderoad

_posts/builder-coderoad/2016-01-01-explanation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: What is Builder-CodeRoad?
3-
id: explanation
3+
link: explanation
44
file: 2016-01-01-explanation.md
55
categories:
66
- builder-coderoad

_posts/builder-coderoad/2016-01-02-installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Quick Start
3-
id: install
3+
link: install
44
file: 2016-01-02-installation.md
55
categories:
66
- builder-coderoad

_posts/builder-coderoad/2016-01-03-development.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Development
3-
id: development
3+
link: development
44
file: 2016-01-02-development.md
55
categories:
66
- builder-coderoad

_posts/tutorial-docs/2016-01-01-tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: Tutorial Markdown
3-
id: tutorial-md
3+
link: tutorial-md
44
file: 2016-01-01-tutorial.md
55
categories:
6-
- docs
6+
- tutorial-docs
77
---
88

99
CodeRoad tutorials are written in Github Flavored Markdown, then parsed into a *coderoad.json* file when you run `> coderoad build`.

_posts/tutorial-docs/2016-01-02-coderoad-api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: CodeRoad API
3-
id: coderoad-API
3+
link: coderoad-API
44
file: 2016-01-02-coderoad-api.md
55
categories:
6-
- docs
6+
- tutorial-docs
77
---
88

99
Of course Markdown couldn't cover all uses necessary for CodeRoad. Instead, there is a special **CodeRoad API** which is parsed into the data file whenever you run `> coderoad build`.

_posts/tutorial-docs/2016-01-03-tests.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: Unit Testing
3-
id: tests
3+
link: tests
44
file: 2016-01-03-tests.md
55
categories:
6-
- docs
6+
- tutorial-docs
77
---
88

99
Unit tests are used to determine:

_posts/tutorial-docs/2016-01-04-loaders.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: Loaders
3-
id: test-loaders
3+
link: test-loaders
44
file: 2016-01-04-loaders.md
55
categories:
6-
- docs
6+
- tutorial-docs
77
---
88

99
Loaders are hidden behind comments, which may differ based on the programming language or compiler.

_posts/tutorial-docs/2016-01-05-test-snippets.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: Test Snippets
3-
id: test-snippets
3+
link: test-snippets
44
file: 2016-01-05-test-snippets.md
55
categories:
6-
- docs
6+
- tutorial-docs
77
---
88
Test Runners may have pre-made [Atom snippets](https://atom.io/docs/latest/using-atom-snippets) to quickly generate test files. See [*mocha-coderoad* snippets](https://github.com/coderoad/mocha-coderoad/blob/master/snippets.cson) as an example.
99

_posts/tutorial-docs/2016-01-06-test-examples.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: Test Examples
3-
id: test-examples
3+
link: test-examples
44
file: 2016-01-06-test-examples.md
55
categories:
6-
- docs
6+
- tutorial-docs
77
---
88

99
Here are examples using *mocha* with *chai*'s *expect*. See the [Chai/Expect docs](http://chaijs.com/api/bdd/). Also keep in mind that most uses cases are covered by [test snippets](#test-snippets).

_posts/tutorial-docs/2016-01-07-config.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: Config
3-
id: config
3+
link: config
44
file: 2016-01-07-config.md
55
categories:
6-
- docs
6+
- tutorial-docs
77
---
88
CodeRoad tutorial configurations can be set in the *package.json* config.
99

_posts/tutorial-docs/2016-01-08-publish.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: Publishing
3-
id: publish
3+
link: publish
44
file: 2016-01-08-publish.md
55
categories:
6-
- docs
6+
- tutorial-docs
77
---
88
Make sure your tutorial is ready and user tested before publishing to NPM.
99

_posts/tutorial-docs/2016-01-09-test-runner.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: Test Runners
3-
id: test-runners
3+
link: test-runners
44
file: 2016-01-09-test-runner.md
55
categories:
6-
- docs
6+
- tutorial-docs
77
---
88
A CodeRoad test runner works by creating a child process and calling a test framework with target files, then returning the result as a JSON object.
99

_posts/tutorial-docs/2016-01-10-roadmap.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: Roadmap
3-
id: roadmap
3+
link: roadmap
44
file: 2016-01-10-roadmap.md
55
categories:
6-
- docs
6+
- tutorial-docs
77
---
88
CodeRoad will become more flexible & powerful with time.
99

_sass/_custom.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
opacity: 0.85;
88
}
99

10+
.doc-contents {
11+
padding-left: 30px;
12+
}
13+
1014
.edit-docs {
1115
float: right;
1216
}

atom-coderoad.html

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,4 @@
55
repo: //github.com/coderoad/atom-coderoad
66
---
77

8-
{% for doc in site.categories.atom-coderoad reversed %}
9-
{% include docs.html
10-
id=doc.id
11-
title=doc.title
12-
content=doc.content
13-
editPath="//github.com/coderoad/coderoad.github.io/edit/master/_posts/atom-coderoad"
14-
file=doc.file
15-
%}
16-
{% endfor %}
8+
{% include docs.html category="atom-coderoad" %}

builder-coderoad.html

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,7 @@
55
repo: //github.com/coderoad/builder-coderoad
66
---
77

8-
{% for doc in site.categories.builder-coderoad reversed %}
9-
{% include docs.html
10-
id=doc.id
11-
title=doc.title
12-
content=doc.content
13-
editPath="//github.com/coderoad/coderoad.github.io/edit/master/_posts/builder-coderoad"
14-
file=doc.file
15-
%}
16-
{% endfor %}
8+
{% include docs.html category="builder-coderoad" %}
179
<!--
1810
<ul>
1911
<li>Installation</li>

js/modals.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,18 @@ $(function() {
2323
threshold : 200,
2424
});
2525

26+
// smooth scroll
27+
$('a[href*="#"]:not([href="#"])').click(function() {
28+
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
29+
var target = $(this.hash);
30+
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
31+
if (target.length) {
32+
$('html, body').animate({
33+
scrollTop: target.offset().top
34+
}, 1000);
35+
return false;
36+
}
37+
}
38+
});
39+
2640
});

tutorial-docs.html

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,6 @@
2323
</ul>
2424
</section>
2525

26-
<!-- Articles -->
27-
{% for doc in site.categories.docs reversed %}
28-
{% include docs.html
29-
id=doc.id
30-
title=doc.title
31-
content=doc.content
32-
editPath="//github.com/coderoad/coderoad.github.io/edit/master/_posts/tutorial-docs"
33-
file=doc.file
34-
%}
35-
{% endfor %}
26+
{% include docs.html category="tutorial-docs" %}
3627

3728
</div>

0 commit comments

Comments
 (0)