on master help sign in
Merge pull request #746 from urbit/mp/docs/side-nav-scroll
d8a0565édouard
components/ContentArea.js+4
@@ -1,5 +1,6 @@
1import Section from "./Section";
1import Section from "./Section";
2import { useState, useEffect } from "react";
2import { useState, useEffect } from "react";
3+import { TableOfContents } from "./TableOfContents";
3
4
4export default function ContentArea(props) {
5export default function ContentArea(props) {
5 const [shortcut, setShortcut] = useState("");
6 const [shortcut, setShortcut] = useState("");
@@ -50,6 +51,9 @@ export default function ContentArea(props) {
50 <div className="pb-32" />
51 <div className="pb-32" />
51 </div>
52 </div>
52 )}
53 )}
54+ <TableOfContents
55+ key={props.params.slug?.join("/") || Math.random()}
56+ />
53 </div>
57 </div>
54 </div>
58 </div>
55 </div>
59 </div>
components/TableOfContents.js+1−1
@@ -8,7 +8,7 @@ export const TableOfContents = ({ staticPosition, noh3s }) => {
8 <nav
8 <nav
9 className={
9 className={
10 (staticPosition ? "static" : "sticky") +
10 (staticPosition ? "static" : "sticky") +
11− " min-h-0 overflow-y-auto w-52 flex-shrink-0 pb-24 hidden lg:block"
11+ " min-h-0 overflow-y-auto w-52 flex-shrink-0 pb-24 hidden lg:block pl-4"
12 }
12 }
13 style={{ top: "8rem", height: "calc(100vh - 16rem)" }}
13 style={{ top: "8rem", height: "calc(100vh - 16rem)" }}
14 >
14 >
pages/community/[[...slug]].js+1
@@ -76,6 +76,7 @@ export default function UsingLayout({ posts, data, params, search, markdown }) {
76 title={data.title}
76 title={data.title}
77 search={search}
77 search={search}
78 section={"Community"}
78 section={"Community"}
79+ params={params}
79 >
80 >
80 <div className={markdownStyles["markdown"]}>
81 <div className={markdownStyles["markdown"]}>
81 <article
82 <article
pages/docs/[[...slug]].js+1−2
@@ -17,7 +17,6 @@ import ContentArea from "../../components/ContentArea";
17import Sidebar from "../../components/Sidebar";
17import Sidebar from "../../components/Sidebar";
18import markdownStyles from "../../styles/markdown.module.css";
18import markdownStyles from "../../styles/markdown.module.css";
19import { decode } from "html-entities";
19import { decode } from "html-entities";
20−import { TableOfContents } from "../../components/TableOfContents";
21
20
22const breadcrumbs = (posts, paths) => {
21const breadcrumbs = (posts, paths) => {
23 const results = [
22 const results = [
@@ -144,6 +143,7 @@ export default function DocsLayout({
144 title={data.title}
143 title={data.title}
145 search={search}
144 search={search}
146 section="Urbit Documentation"
145 section="Urbit Documentation"
146+ params={params}
147 >
147 >
148 <div className={markdownStyles["markdown"]}>
148 <div className={markdownStyles["markdown"]}>
149 <article
149 <article
@@ -175,7 +175,6 @@ export default function DocsLayout({
175 )}
175 )}
176 </div>
176 </div>
177 </ContentArea>
177 </ContentArea>
178− <TableOfContents key={params.slug?.join("/") || "docs"} />
179 </div>
178 </div>
180 </>
179 </>
181 );
180 );
pages/getting-started/[[...slug]].js+1−2
@@ -7,7 +7,6 @@ import { join } from "path";
7import { buildPageTree, getPage } from "../../lib/lib";
7import { buildPageTree, getPage } from "../../lib/lib";
8import Markdown from "../../components/Markdown";
8import Markdown from "../../components/Markdown";
9import ContentArea from "../../components/ContentArea";
9import ContentArea from "../../components/ContentArea";
10−import { TableOfContents } from "../../components/TableOfContents";
11import Sidebar from "../../components/Sidebar";
10import Sidebar from "../../components/Sidebar";
12import markdownStyles from "../../styles/markdown.module.css";
11import markdownStyles from "../../styles/markdown.module.css";
13import { decode } from "html-entities";
12import { decode } from "html-entities";
@@ -94,6 +93,7 @@ export default function UsingLayout({ posts, data, params, search, markdown }) {
94 title={data.title}
93 title={data.title}
95 search={search}
94 search={search}
96 section={"Getting Started"}
95 section={"Getting Started"}
96+ params={params}
97 >
97 >
98 <div className={markdownStyles["markdown"]}>
98 <div className={markdownStyles["markdown"]}>
99 <article
99 <article
@@ -101,7 +101,6 @@ export default function UsingLayout({ posts, data, params, search, markdown }) {
101 ></article>
101 ></article>
102 </div>
102 </div>
103 </ContentArea>
103 </ContentArea>
104− <TableOfContents key={params.slug?.join("/") || "getting-started"} />
105 </div>
104 </div>
106 </>
105 </>
107 );
106 );
pages/understanding-urbit/[[...slug]].js+1
@@ -106,6 +106,7 @@ export default function UnderstandingLayout({
106 title={data.title}
106 title={data.title}
107 search={search}
107 search={search}
108 section={"Understanding Urbit"}
108 section={"Understanding Urbit"}
109+ params={params}
109 >
110 >
110 <div className={markdownStyles["markdown"]}>
111 <div className={markdownStyles["markdown"]}>
111 <article
112 <article
pages/using/[[...slug]].js+1−2
@@ -8,7 +8,6 @@ import { join } from "path";
8import { getDocs, formatDate, buildPageTree, getPage } from "../../lib/lib";
8import { getDocs, formatDate, buildPageTree, getPage } from "../../lib/lib";
9import Markdown from "../../components/Markdown";
9import Markdown from "../../components/Markdown";
10import ContentArea from "../../components/ContentArea";
10import ContentArea from "../../components/ContentArea";
11−import { TableOfContents } from "../../components/TableOfContents";
12import Sidebar from "../../components/Sidebar";
11import Sidebar from "../../components/Sidebar";
13import markdownStyles from "../../styles/markdown.module.css";
12import markdownStyles from "../../styles/markdown.module.css";
14import { decode } from "html-entities";
13import { decode } from "html-entities";
@@ -114,6 +113,7 @@ export default function UsingLayout({ posts, data, params, search, markdown }) {
114 title={data.title}
113 title={data.title}
115 search={search}
114 search={search}
116 section={"Operator's Manual"}
115 section={"Operator's Manual"}
116+ params={params}
117 >
117 >
118 <div className={markdownStyles["markdown"]}>
118 <div className={markdownStyles["markdown"]}>
119 <article
119 <article
@@ -121,7 +121,6 @@ export default function UsingLayout({ posts, data, params, search, markdown }) {
121 ></article>
121 ></article>
122 </div>
122 </div>
123 </ContentArea>
123 </ContentArea>
124− <TableOfContents key={params.slug?.join("/") || "using"} />
125 </div>
124 </div>
126 </>
125 </>
127 );
126 );