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
66 changes: 49 additions & 17 deletions sidebars-next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import type { SidebarsConfig } from '@docusaurus/plugin-content-docs';

const sidebars: SidebarsConfig = {
docs: [
{
type: 'category',
label: 'Get Started',
collapsible: false,
collapsed: false,
items: [
{
type: 'category',
label: 'Getting Started',
Expand Down Expand Up @@ -174,7 +180,15 @@ const sidebars: SidebarsConfig = {
],
},
],
},
],
},
{
type: 'category',
label: 'Use Doris',
collapsible: false,
collapsed: false,
items: [
{
type: 'category',
label: 'Table Design',
Expand Down Expand Up @@ -712,6 +726,41 @@ const sidebars: SidebarsConfig = {
},
],
},
],
},
{
type: 'category',
label: 'Solutions',
collapsible: false,
collapsed: false,
items: [
{
type: 'category',
label: 'Doris for AI',
link: {type: 'doc', id: 'ai/ai-overview'},
collapsed: true,
items: [
'ai/ai-function-overview',
],
},
{
type: 'category',
label: 'Observability with Doris',
link: {type: 'doc', id: 'observability/overview'},
collapsed: true,
items: [
'observability/log',
'observability/trace',
],
},
],
},
{
type: 'category',
label: 'Operate & Maintain',
collapsible: false,
collapsed: false,
items: [
{
type: 'category',
label: 'Administration',
Expand Down Expand Up @@ -2598,23 +2647,6 @@ const sidebars: SidebarsConfig = {
},
],
},
{
type: 'category',
label: 'Doris for AI',
link: {type: 'doc', id: 'ai/ai-overview'},
collapsed: true,
items: [
'ai/ai-function-overview',
],
},
{
type: 'category',
label: 'Observability with Doris',
link: {type: 'doc', id: 'observability/overview'},
collapsed: true,
items: [
'observability/log',
'observability/trace',
],
},
],
Expand Down
78 changes: 2 additions & 76 deletions src/components/home-next/NavbarNext.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React, { JSX, useState, useEffect } from 'react';
import Link from '@docusaurus/Link';
import { useLocation } from '@docusaurus/router';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem';
import { getLocalePrefix, isDocsNextPath, isReleasesPath, normalizePathname } from '@site/src/utils/locale';
import { getLocalePrefix } from '@site/src/utils/locale';
import { STAR_COUNT } from '@site/src/constant/github.data';
import './NavbarNext.scss';

Expand Down Expand Up @@ -109,33 +107,15 @@ function MenuIcon({ open }: { open: boolean }): JSX.Element {

export function NavbarNext(): JSX.Element {
const {
i18n: { currentLocale, defaultLocale, localeConfigs },
i18n: { currentLocale, defaultLocale },
} = useDocusaurusContext();
const { pathname, search, hash } = useLocation();
const [mobileOpen, setMobileOpen] = useState(false);
const localePrefix = getLocalePrefix(currentLocale, defaultLocale);
const docsHref = `${localePrefix}/docs-next/dev/getting-started/what-is-apache-doris`;
const releasesHref = `${localePrefix}/releases/all-release`;
const navItems = buildNavItems(docsHref, releasesHref);
const [expandedMobileItem, setExpandedMobileItem] = useState(navItems[0]?.label ?? '');
const isDocsNextPage = isDocsNextPath(pathname, [defaultLocale, 'zh-CN']);
const isReleasesPage = isReleasesPath(pathname, [defaultLocale, 'zh-CN']);
const showLocaleSwitcher = isDocsNextPage || isReleasesPage;
const homeHref = `${getLocalePrefix(currentLocale, defaultLocale)}/`;
const localeSwitchLabel = currentLocale === 'zh-CN' ? localeConfigs[defaultLocale]?.label ?? 'English' : '中文';
const currentLocalizedPath = normalizePathname(pathname, [defaultLocale, 'zh-CN']);
const buildLocaleHref = (locale: string) =>
`pathname://${locale === defaultLocale ? '' : `/${locale}`}${currentLocalizedPath}${search}${hash}`;
const localeItems = [defaultLocale, 'zh-CN']
.filter((locale, index, arr) => arr.indexOf(locale) === index)
.map(locale => ({
label: localeConfigs[locale]?.label ?? locale,
lang: localeConfigs[locale]?.htmlLang,
to: buildLocaleHref(locale),
target: '_self',
autoAddBaseUrl: false,
className: locale === currentLocale ? 'dropdown__link--active' : '',
}));

useEffect(() => {
if (!mobileOpen) return undefined;
Expand Down Expand Up @@ -186,33 +166,6 @@ export function NavbarNext(): JSX.Element {
</div>

<div className="navbar-next__actions">
{showLocaleSwitcher && (
<DropdownNavbarItem
mobile={false}
label={
<>
<svg
className="icon-language navbar-next__locale-icon"
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
aria-hidden="true"
>
<path
d="M7.75756 14.3L10.5816 6.91667H11.8759L14.7 14.3H13.4057L12.7501 12.4167H9.74113L9.06873 14.3H7.75756ZM10.1109 11.35H12.3467L11.254 8.3H11.2036L10.1109 11.35ZM2.84908 12.45L1.97498 11.5833L5.11841 8.48333C4.72618 8.05 4.38439 7.60267 4.09302 7.14133C3.80165 6.68044 3.54389 6.19444 3.31976 5.68333H4.61412C4.80463 6.06111 5.00635 6.39711 5.21927 6.69133C5.43219 6.986 5.68434 7.29444 5.97571 7.61667C6.43519 7.12778 6.81621 6.62511 7.11879 6.10867C7.42137 5.59178 7.67352 5.03889 7.87523 4.45H1V3.23333H5.33694V2H6.58087V3.23333H10.9178V4.45H9.11916C8.89503 5.18333 8.59805 5.89155 8.22824 6.57467C7.85842 7.25822 7.39895 7.90555 6.84983 8.51667L8.3459 10.0167L7.87523 11.2833L5.95891 9.38333L2.84908 12.45Z"
fill="currentColor"
/>
</svg>
</>
}
items={localeItems}
position="right"
className="navbar-next__locale-dropdown"
aria-label={localeSwitchLabel}
/>
)}
<a
href={`https://github.com/${GITHUB_REPO}`}
target="_blank"
Expand Down Expand Up @@ -281,33 +234,6 @@ export function NavbarNext(): JSX.Element {
</div>

<div className="navbar-next__mobile-actions">
{showLocaleSwitcher && (
<DropdownNavbarItem
mobile={false}
label={
<>
<svg
className="icon-language navbar-next__locale-icon"
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
aria-hidden="true"
>
<path
d="M7.75756 14.3L10.5816 6.91667H11.8759L14.7 14.3H13.4057L12.7501 12.4167H9.74113L9.06873 14.3H7.75756ZM10.1109 11.35H12.3467L11.254 8.3H11.2036L10.1109 11.35ZM2.84908 12.45L1.97498 11.5833L5.11841 8.48333C4.72618 8.05 4.38439 7.60267 4.09302 7.14133C3.80165 6.68044 3.54389 6.19444 3.31976 5.68333H4.61412C4.80463 6.06111 5.00635 6.39711 5.21927 6.69133C5.43219 6.986 5.68434 7.29444 5.97571 7.61667C6.43519 7.12778 6.81621 6.62511 7.11879 6.10867C7.42137 5.59178 7.67352 5.03889 7.87523 4.45H1V3.23333H5.33694V2H6.58087V3.23333H10.9178V4.45H9.11916C8.89503 5.18333 8.59805 5.89155 8.22824 6.57467C7.85842 7.25822 7.39895 7.90555 6.84983 8.51667L8.3459 10.0167L7.87523 11.2833L5.95891 9.38333L2.84908 12.45Z"
fill="currentColor"
/>
</svg>
</>
}
items={localeItems}
position="right"
className="navbar-next__locale-dropdown"
aria-label={localeSwitchLabel}
/>
)}
<a
href={`https://github.com/${GITHUB_REPO}`}
target="_blank"
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/use-is-doc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState, useEffect } from 'react';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import { isDocsPath } from '@site/src/utils/locale';
import { isDocsPath, isDocsNextPath } from '@site/src/utils/locale';

export default function useIsDocPage(defaultValue: boolean) {
const [isDocsPage, setIsDocsPage] = useState(defaultValue);
Expand All @@ -9,7 +9,7 @@ export default function useIsDocPage(defaultValue: boolean) {
} = useDocusaurusContext();
useEffect(() => {
if (typeof window !== 'undefined') {
const docsPage = isDocsPath(location.pathname, locales);
const docsPage = isDocsPath(location.pathname, locales) || isDocsNextPath(location.pathname, locales);
setIsDocsPage(docsPage);
}
}, [locales, typeof window !== 'undefined' && location.pathname]);
Expand Down
101 changes: 101 additions & 0 deletions src/theme/DocBreadcrumbs/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import React from 'react';
import clsx from 'clsx';
import { ThemeClassNames } from '@docusaurus/theme-common';
import { useSidebarBreadcrumbs } from '@docusaurus/plugin-content-docs/client';
import { useHomePageRoute } from '@docusaurus/theme-common/internal';
import Link from '@docusaurus/Link';
import { translate } from '@docusaurus/Translate';
import HomeBreadcrumbItem from '@theme/DocBreadcrumbs/Items/Home';

import styles from './styles.module.css';

function BreadcrumbsItemLink({
children,
href,
isLast,
}: {
children: React.ReactNode;
href: string | undefined;
isLast: boolean;
}) {
const className = 'breadcrumbs__link';
if (isLast) {
return (
<span className={className} itemProp="name">
{children}
</span>
);
}
return href ? (
<Link className={className} href={href} itemProp="item">
<span itemProp="name">{children}</span>
</Link>
) : (
<span className={className}>{children}</span>
);
}

function BreadcrumbsItem({
children,
active,
index,
addMicrodata,
}: {
children: React.ReactNode;
active: boolean;
index: number;
addMicrodata: boolean;
}) {
return (
<li
{...(addMicrodata && {
itemScope: true,
itemProp: 'itemListElement',
itemType: 'https://schema.org/ListItem',
})}
className={clsx('breadcrumbs__item', {
'breadcrumbs__item--active': active,
})}
>
{children}
<meta itemProp="position" content={String(index + 1)} />
</li>
);
}

export default function DocBreadcrumbs(): JSX.Element | null {
const breadcrumbs = useSidebarBreadcrumbs();
const homePageRoute = useHomePageRoute();
if (!breadcrumbs) {
return null;
}
// Drop the top-level sidebar section group (e.g. "Get Started"),
// since it's a visual grouping and has no destination page.
const visibleBreadcrumbs = breadcrumbs.length > 1 ? breadcrumbs.slice(1) : breadcrumbs;
return (
<nav
className={clsx(ThemeClassNames.docs.docBreadcrumbs, styles.breadcrumbsContainer)}
aria-label={translate({
id: 'theme.docs.breadcrumbs.navAriaLabel',
message: 'Breadcrumbs',
description: 'The ARIA label for the breadcrumbs',
})}
>
<ul className="breadcrumbs" itemScope itemType="https://schema.org/BreadcrumbList">
{homePageRoute && <HomeBreadcrumbItem />}
{visibleBreadcrumbs.map((item, idx) => {
const isLast = idx === visibleBreadcrumbs.length - 1;
const href =
item.type === 'category' && (item as any).linkUnlisted ? undefined : (item as any).href;
return (
<BreadcrumbsItem key={idx} active={isLast} index={idx} addMicrodata={!!href}>
<BreadcrumbsItemLink href={href} isLast={isLast}>
{item.label}
</BreadcrumbsItemLink>
</BreadcrumbsItem>
);
})}
</ul>
</nav>
);
}
4 changes: 4 additions & 0 deletions src/theme/DocBreadcrumbs/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.breadcrumbsContainer {
--ifm-breadcrumb-size-multiplier: 0.8;
margin-bottom: 0.8rem;
}
Loading
Loading