mirror of
https://github.com/supabase/supabase.git
synced 2026-06-02 19:02:06 +08:00
refactor: simplify reference docs nav menu & code split
This commit is contained in:
@@ -1,6 +1,31 @@
|
||||
import { ICommonItem } from '~/components/reference/Reference.types'
|
||||
|
||||
// check if the link is allowed to be displayed
|
||||
export function isFuncNotInLibraryOrVersion(id, type, allowedKeys) {
|
||||
if (id && allowedKeys && !allowedKeys.includes(id) && type !== 'markdown') {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively filter common sections and their sub items based on
|
||||
* what is available in their spec
|
||||
*/
|
||||
export function deepFilterSections(sections: ICommonItem[], specFunctionIds: string[]) {
|
||||
return sections
|
||||
.filter(
|
||||
(section) =>
|
||||
section.type === 'category' ||
|
||||
section.type === 'markdown' ||
|
||||
specFunctionIds.includes(section.id)
|
||||
)
|
||||
.map((section) => {
|
||||
if ('items' in section) {
|
||||
return {
|
||||
...section,
|
||||
items: deepFilterSections(section.items, specFunctionIds),
|
||||
}
|
||||
}
|
||||
return section
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user