sort docs content by order field in frontmatter metadata
All checks were successful
Deploy / deploy (ubuntu-latest, 2.44.0) (push) Successful in 1m1s
All checks were successful
Deploy / deploy (ubuntu-latest, 2.44.0) (push) Successful in 1m1s
Took 7 minutes
This commit is contained in:
parent
68fae2e29e
commit
54230367e1
@ -2,6 +2,7 @@
|
||||
title: '🚀 Introduction'
|
||||
published: '2024-10-06'
|
||||
summary: 'petentium usu tota noluisse errem elaboraret auctor.'
|
||||
order: 1
|
||||
---
|
||||
|
||||
> [!IMPORTANT]
|
||||
|
@ -2,6 +2,7 @@
|
||||
title: '🐋 Docker'
|
||||
published: '2024-10-07'
|
||||
summary: 'petentium usu tota noluisse errem elaboraret auctor.'
|
||||
order: 4
|
||||
---
|
||||
|
||||
# Deploying on Docker
|
||||
|
@ -2,6 +2,7 @@
|
||||
title: '🧩 Components'
|
||||
published: '2024-10-07'
|
||||
summary: 'petentium usu tota noluisse errem elaboraret auctor.'
|
||||
order: 2
|
||||
---
|
||||
|
||||
# Components
|
||||
|
@ -2,6 +2,7 @@
|
||||
title: '✔️ Supported Services'
|
||||
published: '2024-10-07'
|
||||
summary: 'petentium usu tota noluisse errem elaboraret auctor.'
|
||||
order: 3
|
||||
---
|
||||
|
||||
# Supported Services
|
||||
|
@ -16,6 +16,11 @@ type DocsContentMetadata = MDXMetadata & {
|
||||
* The summary of this content.
|
||||
*/
|
||||
summary: string;
|
||||
|
||||
/**
|
||||
* The order of this content.
|
||||
*/
|
||||
order: number;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -136,7 +136,16 @@ const CategoryItem = ({
|
||||
const buildTree = (pages: DocsContentMetadata[]): Record<string, TreeNode> => {
|
||||
const tree: Record<string, TreeNode> = {};
|
||||
|
||||
pages.forEach((page: DocsContentMetadata) => {
|
||||
// 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) => {
|
||||
const parts: string[] | undefined = page.slug?.split("/");
|
||||
let currentLevel = tree;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user