diff --git a/CHANGELOG.md b/CHANGELOG.md index f2778c019..52a907610 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,12 @@ +3.2.0 / 2017-02-28 +================== + + * fix(render): Toc rendering error, fixed #106 + * feat(search): Localization for no data tip, close #103 + * fix(fetch): load sidebar and navbar for parent path, fixed #100 + * feat(render) nameLink for each route, fixed #99 + 3.1.2 / 2017-02-27 ================== diff --git a/docs/_coverpage.md b/docs/_coverpage.md index 292a9523b..0f74e8ffa 100644 --- a/docs/_coverpage.md +++ b/docs/_coverpage.md @@ -1,6 +1,6 @@ ![logo](_media/icon.svg) -# docsify 3.1 +# docsify 3.2 > A magical documentation site generator. diff --git a/docs/_sidebar.md b/docs/_sidebar.md index e747a918d..cf254be95 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -17,6 +17,6 @@ - [Helpers](/helpers) - [Vue compatibility](/vue) - [CDN](/cdn) - - [Offline Mode(PWA)new](/pwa) + - [Offline Mode(PWA)](/pwa) - [Changelog](/changelog) \ No newline at end of file diff --git a/docs/configuration.md b/docs/configuration.md index 26e3f0df8..5c997af2f 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -206,7 +206,13 @@ The name of the link. ```js window.$docsify = { - nameLink: '/' + nameLink: '/', + + // For each route + nameLink: { + '/zh-cn/': '/zh-cn/', + '/': '/' + } } ``` diff --git a/docs/plugins.md b/docs/plugins.md index 29f434874..3142694cd 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -27,6 +27,14 @@ By default, the hyperlink on the current page is recognized and the content is s placeholder: { '/zh-cn/': '搜索', '/': 'Type to search' + }, + + noData: 'No Results!', + + // Localization + noData: { + '/zh-cn/': '找不到结果', + '/': 'No Results' } } } diff --git a/docs/zh-cn/_sidebar.md b/docs/zh-cn/_sidebar.md index 47d970e50..d9376b4a1 100644 --- a/docs/zh-cn/_sidebar.md +++ b/docs/zh-cn/_sidebar.md @@ -17,6 +17,6 @@ - [文档助手](zh-cn/helpers) - [兼容 Vue](zh-cn/vue) - [CDN](zh-cn/cdn) - - [离线模式(PWA)new](zh-cn/pwa) + - [离线模式(PWA)](zh-cn/pwa) - [Changelog](zh-cn/changelog) \ No newline at end of file diff --git a/docs/zh-cn/configuration.md b/docs/zh-cn/configuration.md index 28c0af9b3..a474f7d38 100644 --- a/docs/zh-cn/configuration.md +++ b/docs/zh-cn/configuration.md @@ -206,7 +206,13 @@ window.$docsify = { ```js window.$docsify = { - nameLink: '/' + nameLink: '/', + + // 按照路由切换 + nameLink: { + '/zh-cn/': '/zh-cn/', + '/': '/' + } } ``` diff --git a/docs/zh-cn/plugins.md b/docs/zh-cn/plugins.md index aa29eab90..5fa1530a4 100644 --- a/docs/zh-cn/plugins.md +++ b/docs/zh-cn/plugins.md @@ -27,6 +27,14 @@ placeholder: { '/zh-cn/': '搜索', '/': 'Type to search' + }, + + noData: 'No Results!', + + // 支持本地化 + noData: { + '/zh-cn/': '找不到结果', + '/': 'No Results' } } } diff --git a/lib/docsify.js b/lib/docsify.js index 54d5f0666..776c9acc7 100644 --- a/lib/docsify.js +++ b/lib/docsify.js @@ -300,8 +300,12 @@ var isAbsolutePath = cached(function (path) { return /(:|(\/{2}))/.test(path) }); -var getRoot = cached(function (path) { - return /\/$/g.test(path) ? path : path.match(/(\S*\/)[^\/]+$/)[1] +var getParentPath = cached(function (path) { + return /\/$/g.test(path) + ? path + : (path = path.match(/(\S*\/)[^\/]+$/)) + ? path[1] + : '' }); var cleanPath = cached(function (path) { @@ -393,7 +397,7 @@ var route = Object.freeze({ getBasePath: getBasePath, getPath: getPath, isAbsolutePath: isAbsolutePath, - getRoot: getRoot, + getParentPath: getParentPath, cleanPath: cleanPath }); @@ -711,7 +715,7 @@ function main (config) { '' + ''); @@ -2966,7 +2970,6 @@ markdown.init = function (config, base) { if ( base === void 0 ) base = window.location.pathname; contentBase = getBasePath(base); - currentPath = parse().path; if (isFn(config)) { markdownCompiler = config(marked, renderer); @@ -3041,8 +3044,9 @@ function sidebar (text, level) { html = markdown(text); html = html.match(/]*>([\s\S]+)<\/ul>/g)[0]; } else { - var tree$$1 = genTree(toc, level); + var tree$$1 = cacheTree[currentPath] || genTree(toc, level); html = tree(tree$$1, '