From ea87686d7c3b10b6665d4404558b1f955d71029c Mon Sep 17 00:00:00 2001 From: Sahitya Buddharaju <148156994+bsahitya@users.noreply.github.com> Date: Tue, 24 Sep 2024 10:38:40 -0500 Subject: [PATCH] Fix/breadcrumbs (#138) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(breadcrumbs): fix the home page breadcrumb issue * chore(pr_template): move pr template from github workflows --------- Co-authored-by: “Sahitya <“sahitya.buddharaju@gmail.com”> --- .../{workflows => }/PULL_REQUEST_TEMPLATE.md | 0 src/config/header.navitems.js | 4 +--- src/theme/DocBreadcrumbs/Items/Home/index.tsx | 20 ++++++++++++++++--- 3 files changed, 18 insertions(+), 6 deletions(-) rename .github/{workflows => }/PULL_REQUEST_TEMPLATE.md (100%) diff --git a/.github/workflows/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md similarity index 100% rename from .github/workflows/PULL_REQUEST_TEMPLATE.md rename to .github/PULL_REQUEST_TEMPLATE.md diff --git a/src/config/header.navitems.js b/src/config/header.navitems.js index 5e221871f1..c6dac9bd97 100644 --- a/src/config/header.navitems.js +++ b/src/config/header.navitems.js @@ -5,9 +5,7 @@ export default function headerItems(baseUrl = '/', currentLocale = 'en') { title: 'header.title', navItems: [ { - href: `/quickstarts/${ - ['es', 'ja', 'en'].includes(currentLocale) ? locale : '' - }`, + href: `${baseUrl ?? ''}${locale ?? ''}/quickstarts`, label: 'header.getting_started', }, { diff --git a/src/theme/DocBreadcrumbs/Items/Home/index.tsx b/src/theme/DocBreadcrumbs/Items/Home/index.tsx index 255d15b7c5..e8c1e3644d 100644 --- a/src/theme/DocBreadcrumbs/Items/Home/index.tsx +++ b/src/theme/DocBreadcrumbs/Items/Home/index.tsx @@ -4,6 +4,16 @@ import useBaseUrl from '@docusaurus/useBaseUrl'; import { translate } from '@docusaurus/Translate'; import { useActivePlugin } from '@docusaurus/plugin-content-docs/client'; +const getBreadcrumbTranslationId = (activePluginId = ''): string => { + switch (activePluginId) { + case 'quickstarts': + return 'header.getting_started'; + case 'default': + default: + return 'header.docs.ai_unlimited'; + } +}; + export default function HomeBreadcrumbItem() { const homeHref = useBaseUrl('/'); const activePlugin = useActivePlugin(undefined); @@ -11,10 +21,12 @@ export default function HomeBreadcrumbItem() { id: 'theme.docs.breadcrumbs.home', message: 'Home', }); + const docsLabel = translate({ - id: `theme.docs.breadcrumbs.${activePlugin?.pluginId}`, + id: getBreadcrumbTranslationId(activePlugin?.pluginId), message: 'AI Unlimited', - }); + }); + return ( <>
  • @@ -22,7 +34,9 @@ export default function HomeBreadcrumbItem() { aria-label={homeLabel} className="breadcrumbs__link" href={homeHref} - >{homeLabel} + > + {homeLabel} +