From 44ff6ee6dd16d1c1aa0c871b962b3b281699a5bd Mon Sep 17 00:00:00 2001 From: ruanyf Date: Tue, 22 Apr 2014 09:43:38 +0800 Subject: [PATCH] edit document title --- index.html | 2 +- js/ditto.js | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index a5f6477..45c990b 100644 --- a/index.html +++ b/index.html @@ -30,7 +30,7 @@ // essential settings ditto.index = "README.md", ditto.sidebar_file = "sidebar.md", - + ditto.document_title = "ECMAScript 6入门", // where the docs are actually stored on github - so you can edit ditto.base_url = "https://github.com/ruanyf/es6tutorial/edit/gh-pages/"; // <------- EDIT ME!! diff --git a/js/ditto.js b/js/ditto.js index 133809e..6ca2f3b 100644 --- a/js/ditto.js +++ b/js/ditto.js @@ -186,18 +186,21 @@ function router() { $.get(path , function(data) { $(ditto.error_id).hide(); $(ditto.content_id).html(marked(data)); - + if ($(ditto.content_id h1) === ditto.document_title){ + document.title = ditto.document_title; + } else { + document.title = $(ditto.content_id h1).text() + " - " + ditto.document_title; + } normalize_paths(); create_page_anchors(); - + $('#content code').map(function() { + Prism.highlightElement(this); + }); }).fail(function() { show_error(); }).always(function() { clearInterval(loading); - $('#content code').map(function() { - Prism.highlightElement(this); - }); $(ditto.loading_id).hide(); }); }