From 290e7865e9b2fc782a43132f6b547f0e06fbb9b2 Mon Sep 17 00:00:00 2001 From: lichao Date: Tue, 26 Dec 2017 14:04:08 +0800 Subject: [PATCH] fix wrong anchor link in sidebar in API detail page --- themes/vue/source/js/common.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/themes/vue/source/js/common.js b/themes/vue/source/js/common.js index 9ba7686c81..8c970ad052 100644 --- a/themes/vue/source/js/common.js +++ b/themes/vue/source/js/common.js @@ -14,8 +14,9 @@ var apiTitles = [].slice.call(apiContent.querySelectorAll('h3')) apiTitles.forEach(function (titleNode) { var methodMatch = titleNode.textContent.match(/^([^(]+)\(/) + var idWithoutArguments = slugize(titleNode.textContent) if (methodMatch) { - var idWithoutArguments = slugize(methodMatch[1]) + idWithoutArguments = slugize(methodMatch[1]) titleNode.setAttribute('id', idWithoutArguments) titleNode.querySelector('a').setAttribute('href', '#' + idWithoutArguments) } @@ -307,8 +308,13 @@ return '' } }).join('').replace(/\(.*\)$/, '') + var methodMatch = h.textContent.match(/^([^(]+)\(/) + var idWithoutArguments = slugize(h.textContent) + if (methodMatch) { + idWithoutArguments = slugize(methodMatch[1]) + } link.innerHTML = - '' + + '' + htmlEscape(text) + '' return link