2 Commits

Author SHA1 Message Date
71c24bd6cc fix page buttons on the docs page footer being broken for some links
All checks were successful
Deploy / deploy (ubuntu-latest, 2.44.0) (push) Successful in 1m9s
Took 3 minutes
2024-10-07 20:24:34 -04:00
c4f7d4bf7e fix active page indicator on the sidebar being broken for some links
Took 9 minutes
2024-10-07 20:21:35 -04:00
3 changed files with 8 additions and 13 deletions

View File

@ -13,7 +13,7 @@ const DocsFooter = ({
}: {
pages: DocsContentMetadata[];
}): ReactElement => {
const path: string = usePathname();
const path: string = decodeURIComponent(usePathname());
const current: number = pages.findIndex(
(page: DocsContentMetadata) =>

View File

@ -44,7 +44,7 @@ const CategoryItem = ({
depth?: number;
isLast?: boolean;
}) => {
const path = usePathname();
const path = decodeURIComponent(usePathname());
const active =
(path === "/" && node.slug === "intro") || path === `/${node.slug}`;
const [isOpen, setIsOpen] = useState(true);
@ -136,16 +136,7 @@ const CategoryItem = ({
const buildTree = (pages: DocsContentMetadata[]): Record<string, TreeNode> => {
const tree: Record<string, TreeNode> = {};
// Sort pages by the order property
const sortedPages = pages.sort(
(a: DocsContentMetadata, b: DocsContentMetadata) => {
const orderA = a.order ?? Number.MAX_SAFE_INTEGER;
const orderB = b.order ?? Number.MAX_SAFE_INTEGER;
return orderA - orderB;
}
);
sortedPages.forEach((page: DocsContentMetadata) => {
pages.forEach((page: DocsContentMetadata) => {
const parts: string[] | undefined = page.slug?.split("/");
let currentLevel = tree;

View File

@ -21,7 +21,11 @@ export const getDocsContent = (): DocsContentMetadata[] => {
for (const directory of getRecursiveDirectories(DOCS_DIR)) {
content.push(...getMetadata<DocsContentMetadata>(DOCS_DIR, directory));
}
return content;
return content.sort((a: DocsContentMetadata, b: DocsContentMetadata) => {
const orderA = a.order ?? Number.MAX_SAFE_INTEGER;
const orderB = b.order ?? Number.MAX_SAFE_INTEGER;
return orderA - orderB;
});
};
/**