Skip to content

Commit 1e65935

Browse files
authored
DOP-6267: Fix duplication error (#1558)
1 parent 85de376 commit 1e65935

File tree

6 files changed

+28
-12
lines changed

6 files changed

+28
-12
lines changed

netlify.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ command = ". ./build.sh $REPO_NAME $PARSER_VERSION"
77

88
[build.environment]
99
ORG_NAME = "10gen"
10-
REPO_NAME = "cloud-docs"
10+
REPO_NAME = "docs-csharp"
1111
BRANCH_NAME = "main"
12-
SITE_NAME = "atlas"
12+
SITE_NAME = "csharp"
1313
PARSER_VERSION = "v0.20.11"

src/components/UnifiedSidenav/AccordionNav.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { theme } from '../../theme/docsTheme';
77
import useScreenSize from '../../hooks/useScreenSize';
88
import DocsHomeButton from '../Sidenav/DocsHomeButton';
99
import { DownloadButton } from '../OfflineDownloadModal';
10+
import { tocItemKey } from '../../utils/create-toc-key';
1011
import { NavTopContainer, downloadButtonStlying, ArtificialPadding } from './UnifiedSidenav';
1112
import { UnifiedTocNavItem } from './UnifiedTocNavItems';
1213
import { TocItem } from './types';
@@ -119,7 +120,7 @@ export const AccordionNavPanel = ({
119120
<UnifiedTocNavItem
120121
{...navItem}
121122
level={1}
122-
key={navItem.newUrl + navItem.label}
123+
key={tocItemKey(navItem)}
123124
group={true}
124125
isStatic={false}
125126
slug={slug}
@@ -137,7 +138,7 @@ export const AccordionNavPanel = ({
137138
<UnifiedTocNavItem
138139
{...navItems}
139140
level={1}
140-
key={navItems.newUrl + navItems.label}
141+
key={tocItemKey(navItems)}
141142
group={true}
142143
isStatic={true}
143144
slug={slug}

src/components/UnifiedSidenav/DoublePannedNav.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { theme } from '../../theme/docsTheme';
66
import useScreenSize from '../../hooks/useScreenSize';
77
import DocsHomeButton from '../Sidenav/DocsHomeButton';
88
import { DownloadButton } from '../OfflineDownloadModal';
9+
import { tocItemKey } from '../../utils/create-toc-key';
910
import { NavTopContainer, downloadButtonStlying, ArtificialPadding } from './UnifiedSidenav';
1011
import { StaticNavItem, UnifiedTocNavItem } from './UnifiedTocNavItems';
1112
import { UnifiedVersionDropdown } from './UnifiedVersionDropdown';
@@ -116,7 +117,7 @@ export const DoublePannedNav = ({
116117
))}
117118
</div>
118119
{currentL1?.versionDropdown && <UnifiedVersionDropdown contentSite={currentL1?.contentSite} />}
119-
{currentL2s?.items?.length > 0 && (
120+
{currentL2s?.items?.length !== undefined && (
120121
<div className={cx(rightPane)} data-nav-pane="right">
121122
{showDriverBackBtn && (
122123
<BackLink
@@ -127,11 +128,11 @@ export const DoublePannedNav = ({
127128
Back to {currentL1?.label}
128129
</BackLink>
129130
)}
130-
{currentL2s.items?.map((navItems) => (
131+
{currentL2s?.items?.map((navItems) => (
131132
<UnifiedTocNavItem
132133
{...navItems}
133134
level={1}
134-
key={navItems.newUrl + navItems.label}
135+
key={tocItemKey(navItems)}
135136
slug={slug}
136137
isAccordion={false}
137138
setCurrentL1={setCurrentL1}

src/components/UnifiedSidenav/UnifiedTocNavItems.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { isCurrentPage } from '../../utils/is-current-page';
1010
import { theme } from '../../theme/docsTheme';
1111
import { isUnifiedTOCInDevMode } from '../../utils/is-unified-toc-dev';
1212
import { VersionContext } from '../../context/version-context';
13+
import { tocItemKey } from '../../utils/create-toc-key';
1314
import { l1ItemStyling, groupHeaderStyling, l2ItemStyling } from './styles/SideNavItem';
1415
import { UnifiedVersionDropdown } from './UnifiedVersionDropdown';
1516
import { TocItem } from './types';
@@ -113,7 +114,7 @@ export const UnifiedTocNavItem = ({
113114
<UnifiedTocNavItem
114115
{...tocItem}
115116
level={level}
116-
key={tocItem.newUrl + tocItem.label}
117+
key={tocItemKey(tocItem)}
117118
slug={slug}
118119
isStatic={false}
119120
isAccordion={isAccordion}
@@ -134,7 +135,7 @@ export const UnifiedTocNavItem = ({
134135
<UnifiedTocNavItem
135136
{...tocItem}
136137
level={level}
137-
key={tocItem.newUrl + tocItem.label}
138+
key={tocItemKey(tocItem)}
138139
slug={slug}
139140
isStatic={false}
140141
isAccordion={isAccordion}
@@ -157,7 +158,7 @@ export const UnifiedTocNavItem = ({
157158
<UnifiedTocNavItem
158159
{...tocItem}
159160
level={level}
160-
key={tocItem.newUrl + tocItem.label}
161+
key={tocItemKey(tocItem)}
161162
slug={slug}
162163
isAccordion={isAccordion}
163164
setCurrentL2s={setCurrentL2s}
@@ -308,7 +309,7 @@ export const CollapsibleNavItem = ({
308309
<UnifiedTocNavItem
309310
{...item}
310311
level={level + 1}
311-
key={item.newUrl + item.label}
312+
key={tocItemKey(item)}
312313
slug={slug}
313314
setShowDriverBackBtn={setShowDriverBackBtn}
314315
setCurrentL2s={setCurrentL2s}

src/components/Widgets/MarkdownWidget/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ const CopyPageMarkdownButton = ({ className, slug }: CopyPageMarkdownButtonProps
4545
// https://www.mongodb.com/docs/mcp-server/get-started.md
4646
const markdownPath = href?.split('?')[0];
4747
const urlWithoutTrailingSlash = removeTrailingSlash(markdownPath);
48-
const markdownAddress = `${urlWithoutTrailingSlash}.md`;
48+
const markdownAddress =
49+
slug === '/' && urlWithoutTrailingSlash?.includes('localhost:8000') ? null : `${urlWithoutTrailingSlash}.md`;
4950
const { setChatbotClicked, setText } = useChatbotModal();
5051

5152
useEffect(() => {
@@ -56,6 +57,7 @@ const CopyPageMarkdownButton = ({ className, slug }: CopyPageMarkdownButtonProps
5657

5758
// prefetch the markdown
5859
const fetchMarkDown = async () => {
60+
if (!markdownAddress) return;
5961
const response = await fetch(markdownAddress, { signal });
6062
if (response?.ok) {
6163
const text = await response.text();
@@ -94,6 +96,7 @@ const CopyPageMarkdownButton = ({ className, slug }: CopyPageMarkdownButtonProps
9496
};
9597

9698
const viewMarkdown = () => {
99+
if (!markdownAddress) return;
97100
window.location.href = markdownAddress;
98101
};
99102

src/utils/create-toc-key.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { TocItem } from '../components/UnifiedSidenav/types';
2+
3+
// Ensures a unique key is created for each toc item
4+
export const tocItemKey = (tocItem: TocItem): string => {
5+
return (
6+
tocItem.newUrl +
7+
tocItem.label +
8+
`${tocItem.versions ? (tocItem.versions.includes ? 'include list' : 'exclude list') : ''}`
9+
);
10+
};

0 commit comments

Comments
 (0)