Skip to content

Commit 9643d04

Browse files
authored
Merge pull request markedjs#1316 from styfle/docs-nav
Add navigation sidebar to the docs
2 parents 461e594 + e77a7be commit 9643d04

File tree

5 files changed

+115
-55
lines changed

5 files changed

+115
-55
lines changed

docs/CONTRIBUTING.md

-3
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,3 @@ To build your own minified version of Marked:
9090
npm run build
9191
```
9292

93-
## Publishing
94-
95-
Creating GitHub releases and publishing to NPM is limited to conributors and owners. If you would like more information, please see our [publishing documentation](#/PUBLISHING.md).
File renamed without changes.

docs/README.md

-29
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
<ul>
2-
<li><a href="#marked">About</a></li>
3-
<li><a href="#demo">Demo</a></li>
4-
<li><a href="#installation">Installation</a></li>
5-
<li><a href="#usage">Usage</a></li>
6-
<li><a href="#specifications">Supported Markdown specifications</a></li>
7-
<li><a href="#security">Security</a></li>
8-
<li><a href="#contributing">Contributing</a></li>
9-
<li><a href="#authors">Authors</a></li>
10-
<li><a href="#license">License</a></li>
11-
</ul>
12-
13-
<h2 id="marked">Marked</h2>
14-
151
Marked is
162

173
1. built for speed.<sup>*</sup>
@@ -97,18 +83,3 @@ The only completely secure system is the one that doesn't exist in the first pla
9783

9884
Therefore, please disclose potential security issues by email to the project [committers](#/AUTHORS.md) as well as the [listed owners within NPM](https://docs.npmjs.com/cli/owner). We will provide an initial assessment of security reports within 48 hours and should apply patches within 2 weeks (also, feel free to contribute a fix for the issue).
9985

100-
<h2 id="contributing">Contributing</h2>
101-
102-
The marked community enjoys a spirit of collaboration and contribution from all comers. Whether you're just getting started with Markdown, JavaScript, and Marked or you're a veteran with it all figured out, we're here to help each other improve as professionals while helping Marked improve technically. Please see our [contributing documentation](#/CONTRIBUTING.md) for more details.
103-
104-
For our Contribution License Agreement, see our [license](https://github.com/markedjs/marked/blob/master/LICENSE.md).
105-
106-
<h2 id="authors">Authors</h2>
107-
108-
For list of credited authors and contributors, please see our [authors page](#/AUTHORS.md).
109-
110-
<h2 id="license">License</h2>
111-
112-
Copyright (c) 2011-2018, Christopher Jeffrey. (MIT License)
113-
114-
See [license](https://github.com/markedjs/marked/blob/master/LICENSE.md) for more details.

docs/USING_PRO.md

-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22

33
To champion the single-reponsibility and open/closed prinicples, we have tried to make it relatively painless to extend marked. If you are looking to add custom functionality, this is the place to start.
44

5-
<ul>
6-
<li><a href="#renderer">The renderer</a></li>
7-
<li><a href="#lexer">The lexer</a></li>
8-
<li><a href="#parser">The parser</a></li>
9-
</ul>
10-
115
<h2 id="renderer">The renderer</h2>
126

137
The renderer is...

docs/index.html

+115-17
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,67 @@
99
font-size: 16px;
1010
line-height: 1.5;
1111
word-wrap: break-word;
12+
background: #F9F9F9;
1213
}
1314

1415
#container {
15-
position: relative;
16-
max-width: 800px;
16+
max-width: 900px;
1717
margin: auto;
18-
padding: 10px;
18+
}
19+
20+
#content {
21+
padding: 5px 10px;
22+
border: 1px solid #ddd;
23+
border-radius: 3px;
24+
background: white;
25+
}
26+
27+
#content h1:first-child {
28+
margin-top: 0px;
29+
}
30+
31+
nav {
1932
border: 1px solid #ddd;
2033
border-radius: 3px;
34+
background: white;
35+
margin-right: 10px;
2136
}
2237

23-
header { display: flex; }
38+
nav > ul {
39+
position: sticky;
40+
top: 5px;
41+
margin: 10px 0px;
42+
padding: 0;
43+
list-style-type: none;
44+
font-size: 14px;
45+
}
46+
47+
nav > ul > li {
48+
min-width: 125px;
49+
padding: 0px 15px;
50+
}
51+
52+
nav > ul > li > ul {
53+
padding-left: 25px;
54+
}
55+
56+
nav > ul > li > ul > li {
57+
font-size: 0.8em;
58+
}
59+
60+
nav .selected {
61+
color: #111;
62+
font-weight: bold;
63+
}
64+
65+
nav .selected:hover {
66+
text-decoration: none;
67+
}
68+
69+
header {
70+
display: flex;
71+
height: 50px;
72+
}
2473

2574
header h1 { margin: 0; }
2675

@@ -62,28 +111,69 @@
62111
border-radius: 3px;
63112
}
64113

65-
.github-ribbon {
66-
position: absolute;
67-
top: 0;
68-
right: 0;
69-
border: 0;
70-
}
114+
.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}
115+
71116
</style>
72117
</head>
73118
<body>
119+
<a href="https://github.com/markedjs/marked" class="github-corner" aria-label="View source on Github">
120+
<svg width="80" height="80" viewBox="0 0 250 250" style="fill:#202020; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true">
121+
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
122+
<path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
123+
<path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path>
124+
</svg>
125+
</a>
74126
<div id="container">
75127
<header>
76128
<a href="#/README.md">
77129
<img src="img/logo-black.svg" height="64px" width="64px" />
78130
</a>
79131
<h1>Marked.js Documentation</h1>
80132
</header>
81-
82-
<a href="https://github.com/markedjs/marked">
83-
<img class="github-ribbon" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub">
84-
</a>
85-
86-
<div id="content"></div>
133+
<div style="display: flex">
134+
<nav>
135+
<ul>
136+
<li>
137+
<a href="#/README.md">Getting Started</a>
138+
<ul>
139+
<li><a href="#/README.md#demo">Demo</a></li>
140+
<li><a href="#/README.md#installation">Installation</a></li>
141+
<li><a href="#/README.md#usage">Usage</a></li>
142+
<li><a href="#/README.md#specifications">Specs</a></li>
143+
<li><a href="#/README.md#security">Security</a></li>
144+
</ul>
145+
</li>
146+
<li>
147+
<a href="#/USING_ADVANCED.md">Advanced Usage</a>
148+
<ul>
149+
<li><a href="#/USING_ADVANCED.md#options">Options</a></li>
150+
<li><a href="#/USING_ADVANCED.md#highlight">Highlighting</a></li>
151+
</ul>
152+
</li>
153+
<li>
154+
<a href="#/USING_PRO.md">Extensibility</a>
155+
<ul>
156+
<li><a href="#/USING_PRO.md#renderer">Renderer</a></li>
157+
<li><a href="#/USING_PRO.md#lexer">Lexer</a></li>
158+
<li><a href="#/USING_PRO.md#parser">Parser</a></li>
159+
</ul>
160+
</li>
161+
<li>
162+
<a href="#/CONTRIBUTING.md">Contributing</a>
163+
<ul>
164+
<li><a href="#/CONTRIBUTING.md#design-principles">Design Principles</a></li>
165+
<li><a href="#/CONTRIBUTING.md#priorities">Priorities</a></li>
166+
<li><a href="#/CONTRIBUTING.md#test-early-often-and-everything">Testing</a></li>
167+
</ul>
168+
</li>
169+
<li><a href="#/CODE_OF_CONDUCT.md">Code of Conduct</a></li>
170+
<li><a href="#/AUTHORS.md">Authors</a></li>
171+
<li><a href="#/PUBLISHING.md">Publishing</a></li>
172+
<li><a href="#/LICENSE.md">License</a></li>
173+
</ul>
174+
</nav>
175+
<div id="content"></div>
176+
</div>
87177
</div>
88178
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
89179
<script src="https://cdn.jsdelivr.net/npm/es6-promise/dist/es6-promise.js"></script>
@@ -98,6 +188,7 @@ <h1>Marked.js Documentation</h1>
98188

99189
var content = document.querySelector('#content');
100190
var body = document.querySelector('html');
191+
var navLinks = document.querySelectorAll('nav a');
101192
var currentPage = 'README.md';
102193
var currentHash = '';
103194
var renderedPage = '';
@@ -125,7 +216,14 @@ <h1>Marked.js Documentation</h1>
125216
fetchAnchor(currentHash)
126217
});
127218

128-
history.replaceState('', document.title, '#/' + currentPage + (currentHash ? '#' + currentHash : ''));
219+
var url = '#/' + currentPage + (currentHash ? '#' + currentHash : '');
220+
var fullUrl = window.location.origin + '/' + url;
221+
222+
navLinks.forEach(function(link) {
223+
link.className = link.href === fullUrl ? 'selected' : '';
224+
});
225+
226+
history.replaceState('', document.title, url);
129227
}
130228

131229
function fetchAnchor(anchor) {

0 commit comments

Comments
 (0)