Skip to content

Commit

Permalink
remove basePath
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Lozano committed Dec 13, 2023
1 parent 4df2e6a commit 38b9787
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
3 changes: 1 addition & 2 deletions packages/theme/components/layout/index-cards/IndexCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type DocsItem = (MdxFile | FolderWithoutChildren) & {
}

export function IndexCards({route, folderData}: IndexCardsProps) {
const {basePath} = useRouter()
const filteredData = folderData.filter(item => item.kind === 'MdxPage' && item.route.includes(`${route}/`))

return (
Expand All @@ -31,7 +30,7 @@ export function IndexCards({route, folderData}: IndexCardsProps) {
if (item.kind !== 'MdxPage') return null
return (
<Grid.Column span={{medium: 6}} key={`cell-${item.route}`}>
<Card href={`${basePath}${item.route}`} hasBorder style={{width: '100%'}}>
<Card href={item.route} hasBorder style={{width: '100%'}}>
{item.frontMatter && <Card.Heading>{item.frontMatter.title}</Card.Heading>}
{item.frontMatter && item.frontMatter.description && (
<Card.Description>{item.frontMatter.description}</Card.Description>
Expand Down
9 changes: 6 additions & 3 deletions packages/theme/components/layout/root-layout/Theme.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, {useMemo} from 'react'
import NextLink from 'next/link'
import Head from 'next/head'
import type {Folder, MdxFile, NextraThemeLayoutProps} from 'nextra'
import {useFSRoute} from 'nextra/hooks'
Expand Down Expand Up @@ -36,7 +37,7 @@ const {publicRuntimeConfig} = getConfig()

export function Theme({children, pageOpts}: NextraThemeLayoutProps) {
const {title, frontMatter, headings, filePath, pageMap, route} = pageOpts
const {locale = 'en-US', defaultLocale, basePath} = useRouter()
const {locale = 'en-US', defaultLocale} = useRouter()
const fsPath = useFSRoute()
const {colorMode} = useColorMode()
const {activePath, topLevelNavbarItems, docsDirectories, flatDocsDirectories} = useMemo(
Expand Down Expand Up @@ -96,7 +97,8 @@ export function Theme({children, pageOpts}: NextraThemeLayoutProps) {
<Breadcrumbs>
{siteTitle && (
<Breadcrumbs.Item
href={basePath || '/'}
as={NextLink}
href="/"
sx={{
color: 'var(--brand-InlineLink-color-rest)',
}}
Expand All @@ -107,8 +109,9 @@ export function Theme({children, pageOpts}: NextraThemeLayoutProps) {
{activePath.map((item, index) => {
return (
<Breadcrumbs.Item
as={NextLink}
key={item.name}
href={`${basePath}${item.route}`}
href={item.route}
selected={index === activePath.length - 1}
sx={{
textTransform: 'capitalize',
Expand Down
16 changes: 5 additions & 11 deletions packages/theme/components/layout/sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ function getOcticonForType(type?: string): Icon | undefined {

export function Sidebar({pageMap}: SidebarProps) {
const router = useRouter()
const basePath = router.basePath

const {sidebarLinks}: ThemeConfig = publicRuntimeConfig

Expand Down Expand Up @@ -95,12 +94,7 @@ export function Sidebar({pageMap}: SidebarProps) {

if (item.kind === 'MdxPage') {
return (
<NavList.Item
as={NextLink}
key={item.name}
href={`${basePath}${item.route}`}
sx={{textTransform: 'capitalize'}}
>
<NavList.Item as={NextLink} key={item.name} href={item.route} sx={{textTransform: 'capitalize'}}>
{item.frontMatter?.title ?? item.name}
</NavList.Item>
)
Expand All @@ -115,7 +109,7 @@ export function Sidebar({pageMap}: SidebarProps) {
const shouldShowTabs = indexPage.frontMatter?.['show-tabs'] ?? false
if (shouldShowTabs) {
return (
<NavList.Item as={NextLink} key={indexPage.name} href={`${basePath}${indexPage.route}`}>
<NavList.Item as={NextLink} key={indexPage.name} href={indexPage.route}>
{(indexPage as MdxFile).frontMatter?.title || item.name}
</NavList.Item>
)
Expand All @@ -137,7 +131,7 @@ export function Sidebar({pageMap}: SidebarProps) {
<NavList.Item
as={NextLink}
key={child.name}
href={`${basePath}${child.route}`}
href={child.route}
aria-current={child.route === router.pathname ? 'page' : undefined}
>
{(child as MdxFile).frontMatter?.title || item.name}
Expand All @@ -152,8 +146,8 @@ export function Sidebar({pageMap}: SidebarProps) {
return (
<NavList.Item
as={NextLink}
key={`${(landingPageItem as MdxFile).route}`}
href={`${basePath}${(landingPageItem as MdxFile).route}`}
key={(landingPageItem as MdxFile).route}
href={(landingPageItem as MdxFile).route}
sx={{textTransform: 'capitalize'}}
aria-current={(landingPageItem as MdxFile).route === router.pathname ? 'page' : undefined}
>
Expand Down

0 comments on commit 38b9787

Please sign in to comment.