mirror of
https://kevinblog.sytes.net/Code/Jibo-Revival-Group/JiboViteDocs.git
synced 2026-06-16 22:36:53 +00:00
Initalize
This commit is contained in:
19
node_modules/@lando/vitepress-theme-default-plus/utils/is-active.js
generated
vendored
Normal file
19
node_modules/@lando/vitepress-theme-default-plus/utils/is-active.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
const EXT_RE = /(index)?\.(md|html)$/;
|
||||
const HASH_RE = /#.*$/;
|
||||
const inBrowser = typeof document !== 'undefined';
|
||||
const normalize = path => decodeURI(path).replace(HASH_RE, '').replace(EXT_RE, '');
|
||||
|
||||
export default function isActive(currentPath, matchPath, asRegex) {
|
||||
if (matchPath === undefined) return false;
|
||||
|
||||
currentPath = normalize(`/${currentPath}`);
|
||||
|
||||
if (asRegex) return new RegExp(matchPath).test(currentPath);
|
||||
if (normalize(matchPath) !== currentPath) return false;
|
||||
|
||||
const hashMatch = matchPath.match(HASH_RE);
|
||||
|
||||
if (hashMatch) return (inBrowser ? location.hash : '') === hashMatch[0];
|
||||
|
||||
return true;
|
||||
};
|
||||
Reference in New Issue
Block a user