Skip to content

Commit de2343c

Browse files
committed
Final patch pre input
1 parent 5c9aebb commit de2343c

File tree

13 files changed

+60
-53
lines changed

13 files changed

+60
-53
lines changed

app/docs/[...slug]/page.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import { glob } from 'glob';
22

3-
43
import DocumentationPage from "@/components/DocumentationPage";
54

65

7-
8-
const RELATIVE_DOCS_PATH = '/docs';
9-
106
export default async function Page({ params }: {
117
params: Promise<{ slug: string[] }>;
128
}) {
@@ -53,9 +49,7 @@ const importSlug = async (slug: string[]) => {
5349
const fullPath = `${path}${file}.${ext}`;
5450
try {
5551
return await import(`@/docs/${fullPath}`);
56-
} catch (e) {
57-
console.error(fullPath);
58-
}
52+
} catch {}
5953
}
6054
}
6155

app/docs/navigation.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import type { NavigationItem } from "@/components/DocumentationSidebar";
44

55
// You can update the navigation structure here.
66
export const navigation: NavigationItem[] = [
7-
{ label: "Docs Home", path: "docs/index.md" },
87
{
98
label: "Explore",
109
children: [
@@ -17,8 +16,13 @@ export const navigation: NavigationItem[] = [
1716
children: [
1817
{ label: "Jupyter", path: "docs/jupyter.md" },
1918
{ label: "Notebooks", path: "docs/notebooks.md" },
20-
{ label: "Software", path: "docs/software.md" },
21-
{ label: "Data", path: "docs/data.md" }
19+
{
20+
label: "Data",
21+
path: "docs/data.md",
22+
children: [
23+
{ label: "Software", path: "docs/software.md" }
24+
]
25+
}
2226
]
2327
},
2428
{
File renamed without changes.

app/get-started/layout.tsx

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,11 @@
11
import type {Metadata} from "next";
22
import Container from "@mui/material/Container";
3-
import SubHeader from "@/components/SubHeader";
43

54
export const metadata: Metadata = {
65
title: "Get Started",
76
description: "Getting started with CHTC Notebook Service",
87
};
98

10-
const SUB_PAGES = [
11-
{
12-
title: "Is BadgerHub for Me?",
13-
href: "#is-badgerhub-for-me",
14-
},
15-
{
16-
title: "Take the Canvas Course",
17-
href: "#take-the-canvas-course",
18-
},
19-
{
20-
title: "Login to BadgerHub",
21-
href: "#login-to-badgerhub",
22-
},
23-
];
249

2510
export default function Layout({
2611
children,
@@ -29,7 +14,6 @@ export default function Layout({
2914
}>) {
3015
return (
3116
<>
32-
<SubHeader links={SUB_PAGES} />
3317
<Container maxWidth="lg" sx={{py: 4}}>
3418
<main>
3519
{children}

app/get-started/page.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import DocumentationPage from "@/components/DocumentationPage";
2+
3+
import MDX, { frontmatter, tableOfContents } from './get-started.mdx';
4+
5+
export default async function Page() {
6+
return (
7+
<DocumentationPage Page={MDX} tocEntries={tableOfContents} frontMatter={frontmatter} />
8+
)
9+
}

app/policies/page.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import DocumentationPage from "@/components/DocumentationPage";
2+
import MDX, { frontmatter, tableOfContents } from './policies.mdx';
3+
4+
export default async function Page() {
5+
return (
6+
<DocumentationPage Page={MDX} tocEntries={tableOfContents} frontMatter={frontmatter} />
7+
)
8+
}
File renamed without changes.

app/types.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Extend the module declaration for MDX files to include custom exports.
3+
*/
4+
declare module '*.mdx' {
5+
import { TableOfContentsEntry } from '@/components/types';
6+
7+
export const tableOfContents: TableOfContentsEntry[];
8+
export const frontmatter: Record<string, unknown>;
9+
}

components/DocumentationPage/DocumentationPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const DocumentationPage = ({Page, tocEntries}: DocumentationPageProps) => {
1818
<Page />
1919
</Grid>
2020
<Grid size={3}>
21-
<Box sx={{padding: 2, position: 'sticky', top: 16}}>
21+
<Box sx={{padding: 2, position: 'sticky', top: 70}}>
2222
<TableOfContents entries={tocEntries} />
2323
</Box>
2424
</Grid>

components/DocumentationSidebar/DocumentationSidebar.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use client';
22

33
import React, { useState } from 'react';
4-
import Link from 'next/link';
54
import Box from '@mui/material/Box';
65
import List from '@mui/material/List';
76
import ListItem from '@mui/material/ListItem';
@@ -11,8 +10,9 @@ import Collapse from '@mui/material/Collapse';
1110
import Typography from '@mui/material/Typography';
1211
import ExpandLess from '@mui/icons-material/ExpandLess';
1312
import ExpandMore from '@mui/icons-material/ExpandMore';
14-
import MuiLink from '@mui/material/Link';
13+
import Link from '@mui/material/Link';
1514
import type { NavigationItem } from './types';
15+
import {usePathname} from "next/navigation";
1616

1717
function NavigationFolder({ items, level = 0 }: { items: NavigationItem[]; level?: number }) {
1818
return (
@@ -25,6 +25,9 @@ function NavigationFolder({ items, level = 0 }: { items: NavigationItem[]; level
2525
}
2626

2727
function NavigationNode({ item, level }: { item: NavigationItem; level: number }) {
28+
29+
const pathname = usePathname()
30+
2831
const [open, setOpen] = useState(level < 1);
2932
const hasChildren = !!item.children && item.children.length > 0;
3033
if (hasChildren) {
@@ -47,13 +50,16 @@ function NavigationNode({ item, level }: { item: NavigationItem; level: number }
4750
</>
4851
);
4952
}
53+
5054
// Leaf node (link)
55+
const href = `/${item.path?.replace(/\.mdx?$|\/index\.md$/, '') || ''}/`
56+
const isActive = pathname === href
5157
return (
52-
<ListItem disablePadding sx={{ pl: (level + 1) * 2 }}>
53-
<MuiLink component={Link} href={`/${item.path?.replace(/\.mdx?$|\/index\.md$/, '') || ''}`} underline="hover" color="inherit">
54-
<ListItemText primary={item.label} />
55-
</MuiLink>
56-
</ListItem>
58+
<Link href={href} underline="hover" color={isActive ? 'primary.main' : 'text.primary'} fontWeight={isActive ? 600 : 400}>
59+
<ListItem sx={{ pl: (level + 1) * 2 }}>
60+
{item.label}
61+
</ListItem>
62+
</Link>
5763
);
5864
}
5965

0 commit comments

Comments
 (0)