Skip to content

Commit 9062aa9

Browse files
committed
hide hidden files/directories ( starts with _ )
1 parent 1618960 commit 9062aa9

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/collections.ts

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export const AriaDocsCollection = new Directory({
3333
basePath: "aria-docs",
3434
loaders: {
3535
mdx: withSchema<DocSchema>(
36-
// {frontmatter: frontmatterSchema},
3736
(path) => import(`@content/docs/aria-docs/${path}.mdx`),
3837
),
3938
},

src/lib/navigation.ts

+18-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ export interface TreeItem {
1111
children?: TreeItem[]
1212
}
1313

14+
/**
15+
* Checks if an entry is hidden (starts with an underscore)
16+
*
17+
* @param entry {EntryType} the entry to check for visibility
18+
* @returns {boolean}
19+
*/
20+
export function isHidden(entry: EntryType) {
21+
return entry.getBaseName().startsWith("_")
22+
}
23+
1424
/** Create a slug from a string. */
1525
// source: https://github.com/souporserious/renoun/blob/main/packages/renoun/src/utils/create-slug.ts
1626
export function createSlug(input: string) {
@@ -24,6 +34,9 @@ export function createSlug(input: string) {
2434
// source:
2535
// https://github.com/souporserious/renoun/blob/main/packages/renoun/src/file-system/index.test.ts
2636
async function buildTreeNavigation(entry: EntryType): Promise<TreeItem | null> {
37+
if (isHidden(entry)) {
38+
return null
39+
}
2740
if (isDirectory(entry)) {
2841
return {
2942
title: entry.getTitle(),
@@ -58,7 +71,9 @@ async function buildTreeNavigation(entry: EntryType): Promise<TreeItem | null> {
5871
}
5972

6073
export async function getTree(sources: EntryType[]): Promise<TreeItem[]> {
61-
return (await Promise.all(sources.map(buildTreeNavigation))).filter(
62-
(ele) => !!ele,
63-
)
74+
return (
75+
await Promise.all(
76+
sources.filter((ele) => !isHidden(ele)).map(buildTreeNavigation),
77+
)
78+
).filter((ele) => !!ele)
6479
}

0 commit comments

Comments
 (0)