Skip to content

Commit cfa8e48

Browse files
committed
doc: add rel=prev/next for links to adjacent sections
This help people using keyboard navigation or with disabilities to easily browse through pagination. For example, in Vimium, a reader can do `[[` or `]]` to browse through the pages.
1 parent 5708b1a commit cfa8e48

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/rustbook/javascript.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ document.addEventListener("DOMContentLoaded", function(event) {
5757
if (i > 0) {
5858
var prevNode = toc[i-1].cloneNode(true);
5959
prevNode.className = 'left';
60+
prevNode.setAttribute('rel', 'prev');
6061
nav.appendChild(prevNode);
6162
}
6263
if (i < toc.length - 1) {
6364
var nextNode = toc[i+1].cloneNode(true);
6465
nextNode.className = 'right';
66+
nextNode.setAttribute('rel', 'next');
6567
nav.appendChild(nextNode);
6668
}
6769
document.getElementById('page').appendChild(nav);

0 commit comments

Comments
 (0)