sort docs content by order field in frontmatter metadata
All checks were successful
Deploy / deploy (ubuntu-latest, 2.44.0) (push) Successful in 1m1s

Took 7 minutes
This commit is contained in:
Braydon 2024-10-07 20:12:33 -04:00
parent 68fae2e29e
commit 54230367e1
6 changed files with 19 additions and 1 deletions

View File

@ -2,6 +2,7 @@
title: '🚀 Introduction'
published: '2024-10-06'
summary: 'petentium usu tota noluisse errem elaboraret auctor.'
order: 1
---
> [!IMPORTANT]

View File

@ -2,6 +2,7 @@
title: '🐋 Docker'
published: '2024-10-07'
summary: 'petentium usu tota noluisse errem elaboraret auctor.'
order: 4
---
# Deploying on Docker

View File

@ -2,6 +2,7 @@
title: '🧩 Components'
published: '2024-10-07'
summary: 'petentium usu tota noluisse errem elaboraret auctor.'
order: 2
---
# Components

View File

@ -2,6 +2,7 @@
title: '✔️ Supported Services'
published: '2024-10-07'
summary: 'petentium usu tota noluisse errem elaboraret auctor.'
order: 3
---
# Supported Services

View File

@ -16,6 +16,11 @@ type DocsContentMetadata = MDXMetadata & {
* The summary of this content.
*/
summary: string;
/**
* The order of this content.
*/
order: number;
};
/**

View File

@ -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;