Skip to content

Commit 45ca7db

Browse files
committed
adding permalinks
Signed-off-by: Vanessa Sochat <[email protected]>
1 parent 27c9859 commit 45ca7db

File tree

5 files changed

+47
-6
lines changed

5 files changed

+47
-6
lines changed

_docs/getting-started.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ tags:
1111

1212
### User Interaction
1313

14-
If you look at any header field on the page, you'll notice three little dots
15-
(called an elipsis) that if you mouse over, will open up to give you options
16-
for Permalink, Edit this Page, and Ask a Question.
14+
15+
On the right side of any page, you'll notice links to edit the page, or
16+
open an issue. The sections also have permalinks added.
1717
These are to ensure that a user is able to link someone else directly to a section
1818
of interest (Permalink), contribute a fix or suggestion to the documentation itself on GitHub
1919
(Edit this page) or open up an issue that links directly to where the user has

_includes/permalinks.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<script>
2+
var headers = ["h1", "h2", "h3", "h4"]
3+
var colors = ["red", "orange", "green", "blue"]
4+
5+
$.each(headers, function(i, header){
6+
var color = colors[i];
7+
$(header).each(function () {
8+
var href=$(this).attr("id");
9+
$(this).append('<a class="headerlink" style="color:' + color + '" href="#' + href + '" title="Permanent link">¶</a>')
10+
});
11+
})
12+
</script>

_includes/toc.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
var toc = $('#TOC');
1010

1111
// Select each header
12-
sections = $('#md-container-pancakes h1');
12+
sections = $('.td-content h1');
1313
$.each(sections, function(idx, v) {
1414
section = $(v);
1515
var div_id = $(section).attr('id');
@@ -20,9 +20,9 @@
2020

2121
// Add section code to subnavigation
2222
var children = $('<nav class="md-nav"><ul class="md-nav__list"></nav></ul>')
23-
var contenders = $("#" + div_id).nextUntil( "h1" );
23+
var contenders = $("#" + div_id).nextUntil("h1");
2424
$.each(contenders, function(idx, contender){
25-
if($(contender).is('h2')) {
25+
if($(contender).is('h2') || $(contender).is('h3')) {
2626
var contender_id = $(contender).attr('id');
2727
var contender_text = $(contender).text().split('¶')[0];
2828
var content = '<li class="md-nav__item"><a class="md-nav__link" href="#' + contender_id + '" title="' + contender_text +'">' + contender_text +'</a></li>';

_layouts/page.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
---
44
{{ content }}
55
{% include toc.html %}
6+
{% include permalinks.html %}

assets/css/main.css

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17946,6 +17946,34 @@ a.text-dark:focus {
1794617946
min-width: 100px
1794717947
}
1794817948

17949+
.headerlink {
17950+
display: inline-block;
17951+
margin-left: 1rem;
17952+
-webkit-transform: translateY(.5rem);
17953+
transform: translateY(.5rem);
17954+
transition: color .25s, opacity .125s .25s, -webkit-transform .25s .25s;
17955+
transition: transform .25s .25s, color .25s, opacity .125s .25s;
17956+
transition: transform .25s .25s, color .25s, opacity .125s .25s, -webkit-transform .25s .25s;
17957+
opacity: 0;
17958+
}
17959+
[dir=rtl] .headerlink {
17960+
margin-right: 1rem;
17961+
margin-left: 0;
17962+
}
17963+
html body .md-typeset .headerlink {
17964+
color: rgba(0, 0, 0, .26);
17965+
}
17966+
17967+
.headerlink {
17968+
opacity: 0;
17969+
}
17970+
17971+
.headerlink:focus, .headerlink:hover {
17972+
-webkit-transform: translate(0);
17973+
transform: translate(0);
17974+
opacity: 1;
17975+
}
17976+
1794917977
@media(max-width:991.98px) {
1795017978
.td-navbar {
1795117979
padding-right: .5rem;

0 commit comments

Comments
 (0)