Skip to content

Commit ac61081

Browse files
committed
Update page.tsx, ContentViewer.module.css,
NavigationBtn.tsx, mdx.tsx, and theme.ts
1 parent 122c25e commit ac61081

File tree

10 files changed

+42
-28
lines changed

10 files changed

+42
-28
lines changed

app/[...markdownPath]/page.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ export default async function Content({
3131
const outline = contentManager.generateOutline();
3232

3333
const { chapterIndex, stepIndex } = contentManager.getStepLocation(mdPath);
34+
const totalChapters = contentManager.getTotalChapters();
35+
const totalSteps = contentManager.getTotalSteps(chapterIndex);
36+
3437
const chapterTitle = outline[chapterIndex].title;
3538

3639
return (
@@ -42,12 +45,14 @@ export default async function Content({
4245
</Link>
4346
<div>
4447
<span>
45-
Chapter {chapterIndex + 1}: {chapterTitle}
48+
Chapter {chapterIndex + 1}: {chapterTitle} (
49+
{((chapterIndex + 1) / totalChapters) * 100}%)
4650
</span>
4751
</div>
4852
<div>
4953
<span>
50-
Step {stepIndex + 1}: {metadata.title}
54+
Step {stepIndex + 1}: {metadata.title} (
55+
{(stepIndex / totalSteps) * 100} %)
5156
</span>
5257
</div>
5358
<ContentViewer>

app/components/ContentViewer/ContentViewer.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
border: 1px solid rgba(0, 0, 0, 0.334);
55
border-radius: 16px;
66
padding: 16px;
7-
width: 50%;
7+
max-width: max(50%, 800px);
88
overflow-y: scroll;
99
height: 100%;
1010
}

app/components/NavigationBtn/NavigationBtn.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default function NavigationBtn({
2121
router.push("/" + path);
2222
}}
2323
>
24-
{direction === "next" ? "Next" : "Previous"}
24+
{direction === "next" ? "NEXT" : "PREVIOUS"}
2525
</Button>
2626
);
2727
}

app/components/mdx.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { MDXRemote, MDXRemoteProps } from "next-mdx-remote/rsc";
2-
import { As, Heading } from "@chakra-ui/react";
2+
import { As, Heading, Link } from "@chakra-ui/react";
3+
34
import { MDXComponents } from "mdx/types";
45

56
function createHeading(level: number): any {
@@ -27,7 +28,7 @@ function createHeading(level: number): any {
2728
as={`h${level}` as As}
2829
size={headingSizes[level]}
2930
lineHeight={"tall"}
30-
letterSpacing={"tighter"}
31+
letterSpacing={"tight"}
3132
>
3233
{children}
3334
</Heading>
@@ -45,7 +46,9 @@ export const components: MDXComponents = {
4546
h4: createHeading(4),
4647
h5: createHeading(5),
4748
h6: createHeading(6),
49+
a: (props) => <Link {...props} style={{ color: "blue" }} target="_" />,
4850
};
51+
4952
export function CustomMDX(props: MDXRemoteProps) {
5053
return (
5154
<MDXRemote

app/styles/theme.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ const Button = {
1212
bg: "hsl(var(--primary))",
1313
_hover: {
1414
bg: "hsl(var(--primary) / 0.8)",
15+
_disabled: {
16+
bg: "hsl(var(--primary) / 0.6)",
17+
},
1518
},
1619
_active: {
1720
bg: "hsl(var(--primary) / 0.6)",
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title : "Welcome"
3+
4+
---
5+
6+
7+
8+
# JSON Schema Tour
9+
Welcome to the JSON Schema Tour! In this interactive tour your will be introduced to JSON Schema. You will learn how to use JSON Schema to validate JSON documents.
10+
11+
12+
### Are there any prerequisites?
13+
**No!** You just need to know what [JSON](https://www.mongodb.com/resources/languages/what-is-json) is.
14+

content/01-introduction/01-why-json-schema.mdx

Lines changed: 0 additions & 17 deletions
This file was deleted.

content/01-introduction/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
---
2-
title: introduction
2+
title: Introduction
33
---

content/outline.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[
22
{
3-
"title": "introduction",
3+
"title": "Introduction",
44
"folderName": "01-introduction",
55
"steps": [
66
{
7-
"title": "Why json schema?",
8-
"fileName": "01-why-json-schema.mdx",
9-
"fullPath": "01-introduction/01-why-json-schema.mdx"
7+
"title": "Welcome",
8+
"fileName": "01-welcome.mdx",
9+
"fullPath": "01-introduction/01-welcome.mdx"
1010
},
1111
{
1212
"title": "Modify an array",

lib/contentManager.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ export default class ContentManager {
157157
);
158158
}
159159
}
160+
public getTotalChapters() {
161+
return this.getOutline().length;
162+
}
163+
public getTotalSteps(chapterIndex: number) {
164+
return this.getOutline()[chapterIndex].steps.length;
165+
}
160166
}
161167

162168
const contentManager = new ContentManager();

0 commit comments

Comments
 (0)