forked from barryclark/jekyll-now
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
From https://github.com/CoryG89/docsync to get relative links working
- Loading branch information
1 parent
8483a60
commit 2ffc698
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* process-rel-links.js | ||
* Author: Cory Gross | ||
* | ||
* This simple jQuery script is called once the DOM structure has been | ||
* completely loaded. In order to make relative linking work correctly on | ||
* the Jekyll based GitHub Pages: we take each anchor on which the inner | ||
* anonymous function is executed, with the function context 'this' set to | ||
* the anchor element on which the function is being called. The function | ||
* simply determines if the extension is .md and removes it if so. | ||
**/ | ||
|
||
$(function () { | ||
$('a').each(function () { | ||
var ext = '.md'; | ||
var href = $(this).attr('href'); | ||
var position = href.length - ext.length; | ||
if (href.substring(position) === ext) | ||
$(this).attr('href', href.substring(0, position)); | ||
}); | ||
}); |