From a7f329d337b05419a00abd60ceac355c8d385c6f Mon Sep 17 00:00:00 2001 From: Mathieu David Date: Fri, 1 Jan 2016 02:17:40 +0100 Subject: [PATCH] Add href to heading anchors so that the url for the anchor is displayed in the url bar when clicking the header --- src/theme/book.css | 8 ++++++++ src/theme/book.js | 2 ++ src/theme/stylus/general.styl | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/src/theme/book.css b/src/theme/book.css index 26e9879a..11224cb8 100644 --- a/src/theme/book.css +++ b/src/theme/book.css @@ -12,6 +12,14 @@ body { .hidden { display: none; } +a h1, +a h2, +a h3, +a h4, +a h5 { + color: #000; + pointer: cursor; +} h2, h3 { margin-top: 2.5em; diff --git a/src/theme/book.js b/src/theme/book.js index ff539546..6ddfc5d6 100644 --- a/src/theme/book.js +++ b/src/theme/book.js @@ -56,6 +56,8 @@ $( document ).ready(function() { content.find("h1, h2, h3, h4, h5").wrap(function(){ var wrapper = $(""); wrapper.attr("name", $(this).text()); + // Add so that when you click the link actually shows up in the url bar... + wrapper.attr("href", $(location).attr('href') + "#" + $(this).text()); return wrapper; }); diff --git a/src/theme/stylus/general.styl b/src/theme/stylus/general.styl index c6d3555b..c8784e5c 100644 --- a/src/theme/stylus/general.styl +++ b/src/theme/stylus/general.styl @@ -15,6 +15,13 @@ html, body { display: none; } +a { + h1, h2, h3, h4, h5 { + color: black; + pointer: cursor; + } +} + h2, h3 { margin-top: 2.5em } h4, h5 { margin-top: 2em }