Skip to content

Commit a27f916

Browse files
authored
fix(docs): table of contents rendering (#73)
This PR fixes the rendering of the table of contents in the docs by using a frontmatter flag to determine during SSR whether a contents sidebar should be rendered.
1 parent a032f67 commit a27f916

File tree

10 files changed

+23
-8
lines changed

10 files changed

+23
-8
lines changed

docs/src/components/Sidebar.module.css

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,6 @@ article ~ .root {
110110
overflow-x: hidden;
111111
overflow-y: auto;
112112
pointer-events: auto;
113-
/* view-transition-name: sidebar; */
114-
115-
&:has(nav:empty) {
116-
@apply hidden;
117-
}
118113

119114
@media (prefers-reduced-motion) {
120115
view-transition-name: none;

docs/src/components/TableOfContents.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ export default function TableOfContents() {
8181
};
8282
}, []);
8383

84-
if (tableOfContents.length < 2) return null;
85-
8684
return (
8785
<>
8886
<header className="text-md font-semibold mb-2 whitespace-nowrap">

docs/src/pages/@contents/[[lang]]/[category]/(table-of-contents).[...slug].page.jsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1+
import { usePathname } from "@lazarv/react-server";
2+
13
import Sidebar from "../../../../components/Sidebar.jsx";
24
import TableOfContents from "../../../../components/TableOfContents.jsx";
5+
import { getPages } from "../../../../pages.mjs";
6+
7+
export default function Contents({ lang, category }) {
8+
const pathname = usePathname();
9+
const { frontmatter } = getPages(pathname, lang)
10+
.find(({ category: c }) => c.toLowerCase() === category.toLowerCase())
11+
?.pages.find(({ langHref }) => langHref === pathname);
12+
13+
if (frontmatter?.contents === false) return null;
314

4-
export default function Contents() {
515
return (
616
<Sidebar id="contents" menu="On this page" right>
717
<TableOfContents />

docs/src/pages/en/(pages)/deploy/api.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import Link from "../../../../components/Link"
1010

1111
By using the Adapter API available in the `@lazarv/react-server-adapter-core` package, you can easily create a deployment adapter for any deployment target.
1212

13+
<Link name="define-the-adapter-handler">
1314
## Define the adapter handler
15+
</Link>
1416

1517
The adapter handler is a function that you need to implement to handle the deployment of your application. It will be called by the build process and it will receive the information needed to prepare the application for deployment.
1618

@@ -55,7 +57,9 @@ You need to pass adapter properties to the `createAdapter` function to configure
5557

5658
`deploy`: The deployment command and arguments. This is optional. When provided, the adapter will show what command the developer needs to run to deploy the application after it has been built. If the `--deploy` flag is provided during the build, the adapter will run this command.
5759

60+
<Link name="adapter-handler">
5861
## Adapter handler
62+
</Link>
5963

6064
The adapter handler function will receive the following properties:
6165

@@ -95,7 +99,9 @@ The `copy` object contains the following functions:
9599
await copy.server(outServerDir);
96100
```
97101

102+
<Link name="helper-functions">
98103
## Helper functions
104+
</Link>
99105

100106
### banner
101107

docs/src/pages/en/(pages)/framework/cluster.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: Cluster mode
33
category: Framework
44
order: 10
5+
contents: false
56
---
67

78
# Cluster Mode

docs/src/pages/en/(pages)/framework/ppr.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: Partial pre-rendering
33
category: Framework
44
order: 5
5+
contents: false
56
---
67

78
# Partial pre-rendering

docs/src/pages/en/(pages)/integrations/mantine.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: Mantine UI
33
category: Integrations
44
order: 5
5+
contents: false
56
---
67

78
import Link from "../../../../components/Link.jsx";

docs/src/pages/en/(pages)/integrations/mui.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: Material UI
33
category: Integrations
44
order: 6
5+
contents: false
56
---
67

78
import Link from "../../../../components/Link.jsx";

docs/src/pages/en/(pages)/integrations/react-query.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: TanStack Query
33
category: Integrations
44
order: 4
5+
contents: false
56
---
67

78
import Link from "../../../../components/Link.jsx";

docs/src/pages/en/(pages)/team/contributors.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title: Contributors
33
category: Team
44
order: 1
55
slug: team/contributors
6+
contents: false
67
---
78

89
import Contributors from "../../../../components/Contributors";

0 commit comments

Comments
 (0)