diff options
author | Steren Giannini <steren.giannini@gmail.com> | 2017-05-17 22:50:19 +0200 |
---|---|---|
committer | Dmitry Lomov <dslomov@google.com> | 2017-05-19 15:07:59 +0200 |
commit | 8dd69b609304bf3f89048dd9446076698c092e1b (patch) | |
tree | bbd1125229a28bb86b6c31303e45b3ba8c98aad1 /site/_layouts | |
parent | f5900474b8bce417c3ef4c3e06af6da5ed57b929 (diff) |
add an edit button on Documentation pages
I successfully tested the change by playing with Chrome DevTools on bazel.build, as I could not find instructions about how to run the site locally :(.
Closes #2992.
PiperOrigin-RevId: 156349018
Diffstat (limited to 'site/_layouts')
-rw-r--r-- | site/_layouts/documentation.html | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/site/_layouts/documentation.html b/site/_layouts/documentation.html index c671b29c17..f15444c1f0 100644 --- a/site/_layouts/documentation.html +++ b/site/_layouts/documentation.html @@ -107,6 +107,27 @@ version_prefix: /versions/master </nav> </div> <div class="col-lg-9"> + <a id="gh-edit" class="default-hidden"><i class="fa fa-pencil" aria-hidden="true"></i> Edit</a> + <script> + var ghDocsBazeURL = 'https://github.com/bazelbuild/bazel/tree/master/site/versions/master/docs/'; + var editButton = document.getElementById('gh-edit'); + // if there is an edit button and we are on a doc page but not in the Build Encyclopedia + if(editButton + && window.location.pathname.split('docs/').length > 1 + && window.location.pathname.lastIndexOf('/be/') == -1) { + var docFile = window.location.pathname.split('docs/')[1]; + // some pages are now using markdown :( + if( docFile !== 'bazel-user-manual.html' + && docFile !== 'build-ref.html' + && docFile !== 'query.html' + && docFile !== 'test-encyclopedia.html') { + docFile = docFile.replace('html', 'md'); + } + editButton.href = ghDocsBazeURL + docFile; + editButton.style.visibility = 'visible'; + } + </script> + {{ content }} </div> </div> |