Skip to content

Commit 9f3b6b9

Browse files
authored
fix(docs): not found page (#75)
Fixes styling and page components on the docs "Not Found" page
1 parent 63ba3e1 commit 9f3b6b9

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

docs/src/pages.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,7 @@ export function getPages(pathname, lang) {
6868
}),
6969
}));
7070
}
71+
72+
export function hasCategory(category) {
73+
return categories?.find((c) => c.toLowerCase() === category?.toLowerCase());
74+
}

docs/src/pages/@breadcrumb/[[lang]]/[category]/(breadcrumb).[...slug].page.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { defaultLanguage } from "../../../../const.mjs";
2+
import { hasCategory } from "../../../../pages.mjs";
23

34
export default function Breadcrumb({ lang, category }) {
5+
if (!hasCategory(category)) {
6+
return null;
7+
}
8+
49
return (
510
<a
611
data-no-content

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import { getPages } from "../../../../pages.mjs";
66

77
export default function Contents({ lang, category }) {
88
const pathname = usePathname();
9-
const { frontmatter } = getPages(pathname, lang)
10-
.find(({ category: c }) => c.toLowerCase() === category.toLowerCase())
11-
?.pages.find(({ langHref }) => langHref === pathname);
9+
const { frontmatter } =
10+
getPages(pathname, lang)
11+
.find(({ category: c }) => c.toLowerCase() === category.toLowerCase())
12+
?.pages.find(({ langHref }) => langHref === pathname) ?? {};
1213

13-
if (frontmatter?.contents === false) return null;
14+
if (!frontmatter || frontmatter?.contents === false) return null;
1415

1516
return (
1617
<Sidebar id="contents" menu="On this page" right>

docs/src/pages/@sidebar/[[lang]]/(sidebar).[...slug].page.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@ import { usePathname } from "@lazarv/react-server";
44

55
import Sidebar from "../../../components/Sidebar.jsx";
66
import { defaultLanguage } from "../../../const.mjs";
7-
import { categories } from "../../../pages.mjs";
7+
import { hasCategory, categories } from "../../../pages.mjs";
88

99
const pages = Array.from(
1010
Object.entries(
1111
import.meta.glob("../../../**/\\(pages\\)/**/*.{md,mdx}", { eager: true })
1212
)
1313
);
1414

15-
export default function PageSidebar({ lang }) {
15+
export default function PageSidebar({ lang, slug: [category] }) {
1616
const pathname = usePathname();
1717

18+
if (!hasCategory(category)) {
19+
return null;
20+
}
21+
1822
return (
1923
<Sidebar id="sidebar" menu="Menu">
2024
{Array.from(

docs/src/pages/en/(404).[[...slug]].page.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export function NotFound() {
77

88
<NotFound />
99

10-
<div className="flex flex-col gap-4 h-full justify-center items-center text-center">
10+
<div className="flex flex-col gap-4 w-full h-full justify-center items-center text-center">
1111
# Not Found
1212

1313
Sorry, this page was not found.

0 commit comments

Comments
 (0)