bump: 3.5.2

This commit is contained in:
qingwei.li 2017-04-05 21:31:22 +08:00
commit be0230ebe9
3 changed files with 14 additions and 4 deletions

View file

@ -1,3 +1,9 @@
# 3.5.2/ 2017-04-05
* add optional current route param to toURL and use it to properly compose local anchor links
* fix code style by removing semicolons
* in toURL test for anchor links and if so prepend the currentPath to the generated path. fixes ([#142](https://github.com/QingWei-Li/docsify/issues/142))
# 3.5.1 / 2017-03-25 # 3.5.1 / 2017-03-25
* fix: .md file extension regex * fix: .md file extension regex

View file

@ -380,14 +380,18 @@ function parse (path) {
* to URL * to URL
* @param {string} path * @param {string} path
* @param {object} qs query params * @param {object} qs query params
* @param {string} currentRoute optional current route
*/ */
function toURL (path, params) { function toURL (path, params, currentRoute) {
var local = currentRoute && path[0] === '#';
var route = parse(replaceSlug(path)); var route = parse(replaceSlug(path));
route.query = merge({}, route.query, params); route.query = merge({}, route.query, params);
path = route.path + stringifyQuery(route.query); path = route.path + stringifyQuery(route.query);
path = path.replace(/\.md(\?)|\.md$/, '$1'); path = path.replace(/\.md(\?)|\.md$/, '$1');
if (local) { path = currentRoute + path; }
return cleanPath('#/' + path) return cleanPath('#/' + path)
} }
@ -3025,7 +3029,7 @@ renderer.code = function (code, lang) {
renderer.link = function (href, title, text) { renderer.link = function (href, title, text) {
var blank = ''; var blank = '';
if (!/:|(\/{2})/.test(href)) { if (!/:|(\/{2})/.test(href)) {
href = toURL(href); href = toURL(href, null, currentPath);
} else { } else {
blank = ' target="_blank"'; blank = ' target="_blank"';
} }

4
lib/docsify.min.js vendored

File diff suppressed because one or more lines are too long