File tree Expand file tree Collapse file tree 1 file changed +17
-16
lines changed
src/app/(frontend)/(pages)/docs Expand file tree Collapse file tree 1 file changed +17
-16
lines changed Original file line number Diff line number Diff line change @@ -33,36 +33,37 @@ export const fetchTopicsForSidebar = async ({
3333 const docs = result . docs
3434
3535 const topicGroups : TopicGroupForNav [ ] = topicOrder [ version ]
36- . map (
37- ( { groupLabel, topics : topicsGroup } ) => ( {
38- groupLabel ,
39- topics : topicsGroup . map ( ( key ) => {
36+ . map ( ( { groupLabel , topics : topicsGroup } ) => ( {
37+ groupLabel,
38+ topics : topicsGroup
39+ . map ( ( key ) => {
4040 const topicSlug = key . toLowerCase ( )
4141
4242 const docsForTopic = docs . filter (
4343 ( doc ) => doc . topic === topicSlug && doc . topicGroup === groupLabel ,
4444 )
4545
4646 const parsedDocs : ParsedDocForNav [ ] = docsForTopic
47- . map ( ( doc ) => {
48- return {
49- slug : doc . slug ,
50- label : doc . label ?? '' ,
51- order : doc . order ?? 0 ,
52- title : doc . title ?? '' ,
53- }
54- } )
47+ . map ( ( doc ) => ( {
48+ slug : doc . slug ,
49+ label : doc . label ?? '' ,
50+ order : doc . order ?? 0 ,
51+ title : doc . title ?? '' ,
52+ } ) )
5553 . filter ( Boolean ) as ParsedDocForNav [ ]
5654
55+ if ( parsedDocs . length === 0 ) {
56+ return null // Omit topics with no docs
57+ }
58+
5759 return {
5860 slug : topicSlug ,
5961 docs : parsedDocs . sort ( ( a , b ) => a . order - b . order ) ,
6062 label : key ,
6163 } as TopicForNav
62- } ) ,
63- } ) ,
64- [ ] ,
65- )
64+ } )
65+ . filter ( Boolean ) , // Remove nulls (topics with no docs)
66+ } ) )
6667 . filter ( Boolean ) as TopicGroupForNav [ ]
6768
6869 return topicGroups
You can’t perform that action at this time.
0 commit comments