Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 74 additions & 22 deletions apify-docs-theme/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,80 +83,132 @@ const themeConfig = {
target: '_self',
rel: 'dofollow',
},
// The dropdown labels below carry both `href` and `to` on purpose. `href` keeps the
// target absolute, so the link resolves from the client, SDK, and CLI docs sites as
// well. `to` tells the Docusaurus dropdown that the label is a real link, so clicking
// it opens the landing page instead of only toggling the menu open.
{
label: 'APIs, SDKs & CLI',
label: 'API',
type: 'dropdown',
activeBaseRegex: '^/(api|sdk|cli)/',
href: `${absoluteUrl}/api`,
to: `${absoluteUrl}/api`,
activeBaseRegex: '^/api(/|$)',
position: 'right',
target: '_self',
rel: 'dofollow',
items: [
{
label: 'API Reference',
label: 'API reference',
href: `${absoluteUrl}/api/v2`,
target: '_self',
rel: 'dofollow',
},
{
label: 'SDK for JavaScript',
href: `${absoluteUrl}/sdk/js/docs/overview`,
label: 'Client for JavaScript',
href: `${absoluteUrl}/api/client/js/docs`,
target: '_self',
rel: 'dofollow',
},
{
label: 'SDK for Python',
href: `${absoluteUrl}/sdk/python/docs/overview`,
label: 'Client for Python',
href: `${absoluteUrl}/api/client/python/docs`,
target: '_self',
rel: 'dofollow',
},
{
label: 'Client for JavaScript',
href: `${absoluteUrl}/api/client/js/docs`,
label: 'Client for Go',
href: `https://github.com/apify/apify-client-go`,
target: '_self',
rel: 'dofollow',
},
{
label: 'Client for Python',
href: `${absoluteUrl}/api/client/python/docs`,
label: 'Client for PHP',
href: `https://github.com/apify/apify-client-php`,
target: '_self',
rel: 'dofollow',
},
{
label: 'CLI',
href: `${absoluteUrl}/cli/docs`,
label: 'Client for Java',
href: `https://github.com/apify/apify-client-java`,
target: '_self',
rel: 'dofollow',
},
{
label: 'Client for .NET',
href: `https://github.com/apify/apify-client-dotnet`,
target: '_self',
rel: 'dofollow',
},
{
label: 'Experimental client for Rust',
label: 'Client for Rust',
href: `https://github.com/apify/apify-client-rust`,
target: '_self',
rel: 'dofollow',
},
],
},
{
label: 'SDK',
type: 'dropdown',
href: `${absoluteUrl}/sdk`,
to: `${absoluteUrl}/sdk`,
activeBaseRegex: '^/sdk(/|$)',
position: 'right',
target: '_self',
rel: 'dofollow',
items: [
{
label: 'Experimental client for Go',
href: `https://github.com/apify/apify-client-go`,
label: 'SDK for JavaScript',
href: `${absoluteUrl}/sdk/js/docs/overview`,
target: '_self',
rel: 'dofollow',
},
{
label: 'Experimental client for PHP',
href: `https://github.com/apify/apify-client-php`,
label: 'SDK for Python',
href: `${absoluteUrl}/sdk/python/docs/overview`,
target: '_self',
rel: 'dofollow',
},
],
},
{
label: 'CLI',
type: 'dropdown',
href: `${absoluteUrl}/cli`,
to: `${absoluteUrl}/cli`,
activeBaseRegex: '^/cli(/|$)',
position: 'right',
target: '_self',
rel: 'dofollow',
items: [
{
label: 'Installation',
href: `${absoluteUrl}/cli/docs/installation`,
target: '_self',
rel: 'dofollow',
},
{
label: 'Experimental client for Java',
href: `https://github.com/apify/apify-client-java`,
label: 'Quick start',
href: `${absoluteUrl}/cli/docs/quick-start`,
target: '_self',
rel: 'dofollow',
},
{
label: 'Experimental client for .NET',
href: `https://github.com/apify/apify-client-dotnet`,
label: 'Command reference',
href: `${absoluteUrl}/cli/docs/reference`,
target: '_self',
rel: 'dofollow',
},
],
},
{
label: 'MCP',
href: `${absoluteUrl}/integrations/mcp`,
activeBasePath: 'integrations/mcp',
position: 'right',
target: '_self',
rel: 'dofollow',
},
],
},
colorMode: {
Expand Down
21 changes: 13 additions & 8 deletions apify-docs-theme/src/theme/NavbarItem/NavbarNavLink.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import { usePluginData } from '@docusaurus/useGlobalData';
import IconExternalLink from '@theme/Icon/ExternalLink';
import clsx from 'clsx';
import React from 'react';

export default function NavbarNavLink({
activeBasePath,
activeBaseRegex,
activeClassName = 'navbar__link--active',
className,
to,
href,
label,
Expand All @@ -30,7 +33,6 @@ export default function NavbarNavLink({
// TODO all this seems hacky
// {to: 'version'} should probably be forbidden, in favor of {to: '/version'}
const toUrl = useBaseUrl(to);
const activeBaseUrl = useBaseUrl(activeBasePath);
const normalizedHref = useBaseUrl(href, { forcePrependBaseUrl: true });
const { siteConfig } = useDocusaurusContext();
const isInternalUrl = (url) => {
Expand Down Expand Up @@ -63,16 +65,18 @@ export default function NavbarNavLink({
.some((item) => (item.to || item.href).endsWith(location.pathname));

if (href) {
// `Link` drops `isActive`/`activeClassName` for absolute URLs (they only work with the
// React Router link), so the active class has to be resolved here instead.
const isActive =
(activeBaseRegex && isRegexpStringMatch(activeBaseRegex, location.pathname)) ||
(activeBasePath && location.pathname.startsWith(`/${activeBasePath}`)) ||
dropDownHasActiveItem;

return (
<Link
href={prependBaseUrlToHref ? normalizedHref : href}
{...props}
{...(activeBaseUrl && {
className:
location.pathname.startsWith(`/${activeBasePath}`) || dropDownHasActiveItem
? 'navbar__item navbar__link navbar__link--active'
: 'navbar__item navbar__link',
})}
className={clsx(className, isActive && activeClassName)}
{...linkContentProps}
/>
);
Expand All @@ -82,13 +86,14 @@ export default function NavbarNavLink({
<Link
to={toUrl}
isNavLink
className={className}
{...((activeBasePath || activeBaseRegex) && {
// eslint-disable-next-line no-shadow
isActive: (_match, location) =>
activeBaseRegex
? isRegexpStringMatch(activeBaseRegex, location.pathname) || dropDownHasActiveItem
: location.pathname.startsWith(`/${activeBasePath}`),
activeClassName: 'navbar__link--active',
activeClassName,
})}
{...props}
{...linkContentProps}
Expand Down
12 changes: 12 additions & 0 deletions apify-docs-theme/src/theme/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,18 @@ div[class*='searchBox'] {
}
}

/*
* Just above the mobile breakpoint the two halves of the nav link row run out of room and
* collide. The switch to the mobile sidebar is pinned to 996px in Docusaurus (both Infima
* and the JS `useWindowSize`), so the row has to fit down to that width instead: tighten
* the spacing between the right-hand links until the layout has room again.
*/
@media (min-width: 997px) and (max-width: 1100px) {
.navbar__inner--subnavbar .navbar__items--right {
gap: 0.4rem;
}
}

/* @media (min-width: 997px) and (max-width: 1250px) {
.navbar__items--right a.icon {
display: none;
Expand Down
1 change: 1 addition & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ module.exports = {
'go',
'csharp',
'powershell',
'rust',
'dart',
'objectivec',
'ocaml',
Expand Down
Loading
Loading