Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function SidebarNav({ items, onClick }) {
// Remove trailing slash to fix activeCss check below.
// Note that netlify will always append a slash to the url so that we end
// up with something like "foo/bar/?lang=de". That's why we first remove
// the search params before removing the trailing slash.
const url = getCurrentUrl()
.replace(/\?.*/, '')
.replace(/\/$/, '');
return (
<nav class="{cx(style.toc," tabindex="0"> 1) && style.disabled)}
>
{items.map(({ text, level, href }) => {
let activeCss = href === url ? style.linkActive : undefined;
return (
<a class="{cx(style.link," href="{href}"></a></nav>
function onChange(e) {
const url = getCurrentUrl().replace(/(v\d{1,2})/, `v${e.target.value}`);
route(url);
}
render(props) {
let url = this.nextUrl || getCurrentUrl(),
path = url.replace(/\?.+$/,'');
this.nextUrl = null;
return props.children({
url,
path,
matches: exec(path, props.path, {}) !== false
});
}
}
function getDefaultState() {
const session = config.gatewayMode ? new GatewaySession() : config.demoMode ? new DemoSession() : new Session();
const httpClient = config.demoMode
? new DemoHttpClient()
: config.gatewayMode
? new GatewayHttpClient(session)
: new HttpClient(session);
const state = {
httpClient,
session,
currentUrl: getCurrentUrl(),
user: {
language: navigator.language === 'fr' ? 'fr' : 'en'
},
showDropDown: false
};
return state;
}