Skip to content

Commit

Permalink
handle sidebar scrolling on state transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
B4nan committed Nov 28, 2024
1 parent 613e287 commit f0a43a6
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions apify-docs-theme/static/js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,25 @@ function scrollOpenApiSidebarItemIntoView() {
});
}

function redirectOpenApiDocs() {
const { hash, pathname } = new URL(window.location.href);

// TODO change to '/api/v2'
if (pathname.replace(/\/$/, '') !== '/api/v2-new') {
return;
}

if (hash.startsWith('#/reference/')) {
const id = hash.substring('/#reference/'.length);
console.log('redirect', { id, hash });

Check warning on line 88 in apify-docs-theme/static/js/custom.js

View workflow job for this annotation

GitHub Actions / Lint app code

Unexpected console statement
}

if (hash.startsWith('#tag/')) {
const id = hash.substring('#tag/'.length);
console.log('redirect', { id, hash });

Check warning on line 93 in apify-docs-theme/static/js/custom.js

View workflow job for this annotation

GitHub Actions / Lint app code

Unexpected console statement
}
}

let ticking = false;

document.addEventListener('scroll', () => {
Expand Down

0 comments on commit f0a43a6

Please sign in to comment.