Skip to content

Commit 2922089

Browse files
committed
fix: get term
1 parent 8e8ac3a commit 2922089

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

main.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,16 @@ const getLang = () => (isEn() ? 'en' : 'zh-CN');
3636
const giscusTheme = () =>
3737
localStorage.getItem('DARK_LIGHT_THEME') === 'light' ? 'light' : 'noborder_dark';
3838

39-
const getTerm = () => decodeURI(location.hash.slice(1, location.hash.lastIndexOf('/')) || '/index');
39+
const getTerm = () => {
40+
let path = decodeURI(location.hash.slice(1, location.hash.lastIndexOf('/'))) || '/index';
41+
// restore original path
42+
for (const prefix of ['javascript', 'database']) {
43+
if (path.includes(prefix + '-solution')) {
44+
path = path.replace(prefix + '-solution', 'solution');
45+
}
46+
}
47+
return path;
48+
};
4049

4150
window.addEventListener('hashchange', () => {
4251
window.$docsify.loadSidebar = sidebar();

0 commit comments

Comments
 (0)