Compare commits
2 Commits
54230367e1
...
71c24bd6cc
Author | SHA1 | Date | |
---|---|---|---|
71c24bd6cc | |||
c4f7d4bf7e |
@ -13,7 +13,7 @@ const DocsFooter = ({
|
|||||||
}: {
|
}: {
|
||||||
pages: DocsContentMetadata[];
|
pages: DocsContentMetadata[];
|
||||||
}): ReactElement => {
|
}): ReactElement => {
|
||||||
const path: string = usePathname();
|
const path: string = decodeURIComponent(usePathname());
|
||||||
|
|
||||||
const current: number = pages.findIndex(
|
const current: number = pages.findIndex(
|
||||||
(page: DocsContentMetadata) =>
|
(page: DocsContentMetadata) =>
|
||||||
|
@ -44,7 +44,7 @@ const CategoryItem = ({
|
|||||||
depth?: number;
|
depth?: number;
|
||||||
isLast?: boolean;
|
isLast?: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
const path = usePathname();
|
const path = decodeURIComponent(usePathname());
|
||||||
const active =
|
const active =
|
||||||
(path === "/" && node.slug === "intro") || path === `/${node.slug}`;
|
(path === "/" && node.slug === "intro") || path === `/${node.slug}`;
|
||||||
const [isOpen, setIsOpen] = useState(true);
|
const [isOpen, setIsOpen] = useState(true);
|
||||||
@ -136,16 +136,7 @@ const CategoryItem = ({
|
|||||||
const buildTree = (pages: DocsContentMetadata[]): Record<string, TreeNode> => {
|
const buildTree = (pages: DocsContentMetadata[]): Record<string, TreeNode> => {
|
||||||
const tree: Record<string, TreeNode> = {};
|
const tree: Record<string, TreeNode> = {};
|
||||||
|
|
||||||
// Sort pages by the order property
|
pages.forEach((page: DocsContentMetadata) => {
|
||||||
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) => {
|
|
||||||
const parts: string[] | undefined = page.slug?.split("/");
|
const parts: string[] | undefined = page.slug?.split("/");
|
||||||
let currentLevel = tree;
|
let currentLevel = tree;
|
||||||
|
|
||||||
|
@ -21,7 +21,11 @@ export const getDocsContent = (): DocsContentMetadata[] => {
|
|||||||
for (const directory of getRecursiveDirectories(DOCS_DIR)) {
|
for (const directory of getRecursiveDirectories(DOCS_DIR)) {
|
||||||
content.push(...getMetadata<DocsContentMetadata>(DOCS_DIR, directory));
|
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;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user