Skip to content

Commit

Permalink
Merge pull request #116 from aslafy-z/feat/frontmatter-order-recursive
Browse files Browse the repository at this point in the history
Blocked: feat: retrieve ordering for top level folder indexes
  • Loading branch information
jooy2 authored Dec 10, 2023
2 parents e36557e + a679b97 commit 21f359a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,17 @@ export default class VitePressSidebar {
) || [];

let newDirectoryText = VitePressSidebar.getTitleFromMd(x, childItemPath, options, true);
let newDirectoryPagePath = childItemPath;
let withDirectoryLink;

if (options.convertSameNameSubFileToGroupIndexPage) {
const findItem = directorySidebarItems.find((y: SidebarListItem) => y.text === x);

if (findItem) {
newDirectoryPagePath = resolve(childItemPath, `${findItem.text}.md`);
newDirectoryText = VitePressSidebar.getTitleFromMd(
x,
resolve(childItemPath, `${findItem.text}.md`),
newDirectoryPagePath,
options,
false
);
Expand All @@ -353,13 +355,13 @@ export default class VitePressSidebar {
// If an index.md file exists in a folder subfile,
// replace the name or link of the folder with what is set in index.md.
// The index.md file can still be displayed if the value of `includeFolderIndexFile` is `true`.
const childIndexFilePath = `${childItemPath}/index.md`;
newDirectoryPagePath = `${childItemPath}/index.md`;

if (existsSync(childIndexFilePath)) {
if (existsSync(newDirectoryPagePath)) {
if (options.useFolderTitleFromIndexFile) {
newDirectoryText = VitePressSidebar.getTitleFromMd(
'index',
childIndexFilePath,
newDirectoryPagePath,
options
);
}
Expand All @@ -376,7 +378,10 @@ export default class VitePressSidebar {
items: directorySidebarItems,
...(options.collapsed === null || options.collapsed === undefined
? {}
: { collapsed: depth >= options.collapseDepth! && options.collapsed })
: { collapsed: depth >= options.collapseDepth! && options.collapsed }),
...(options.sortMenusByFrontmatterOrder
? { order: VitePressSidebar.getOrderFromFrontmatter(newDirectoryPagePath) }

Check failure on line 383 in lib/index.ts

View workflow job for this annotation

GitHub Actions / Test NodeJS 18 on ubuntu-latest

Expected 2 arguments, but got 1.

Check failure on line 383 in lib/index.ts

View workflow job for this annotation

GitHub Actions / Test NodeJS 18 on windows-latest

Expected 2 arguments, but got 1.

Check failure on line 383 in lib/index.ts

View workflow job for this annotation

GitHub Actions / Test NodeJS 18 on macos-latest

Expected 2 arguments, but got 1.

Check failure on line 383 in lib/index.ts

View workflow job for this annotation

GitHub Actions / Test NodeJS 20 on ubuntu-latest

Expected 2 arguments, but got 1.

Check failure on line 383 in lib/index.ts

View workflow job for this annotation

GitHub Actions / Test NodeJS 20 on windows-latest

Expected 2 arguments, but got 1.

Check failure on line 383 in lib/index.ts

View workflow job for this annotation

GitHub Actions / Test NodeJS 20 on macos-latest

Expected 2 arguments, but got 1.
: {})
};
}

Expand Down

0 comments on commit 21f359a

Please sign in to comment.