diff --git a/app.config.ts b/app.config.ts index 2b0cbdf5..7910f827 100644 --- a/app.config.ts +++ b/app.config.ts @@ -68,6 +68,7 @@ export default defineAppConfig({ aside: { useLevel: true, collapse: false, + collapseLevel: 1, folderStyle: 'default', }, main: { diff --git a/components/layout/AsideTreeItem.vue b/components/layout/AsideTreeItem.vue index f1f21bc8..24afd08f 100644 --- a/components/layout/AsideTreeItem.vue +++ b/components/layout/AsideTreeItem.vue @@ -85,7 +85,7 @@ const { link, level } = defineProps<{ level: number; }>(); -const { collapse, folderStyle: defaultFolderStyle } = useConfig().value.aside; +const { collapse, collapseLevel, folderStyle: defaultFolderStyle } = useConfig().value.aside; const collapsed = useCollapsedMap(); const isOpen = ref(collapsed.value.get(link._path) || defaultOpen()); @@ -94,7 +94,7 @@ function defaultOpen() { if (link.collapse !== undefined) return !link.collapse; - return level < 1 && !collapse; + return level < collapseLevel && !collapse; } watch(isOpen, (v) => { diff --git a/composables/useConfig.ts b/composables/useConfig.ts index e7153f78..2220177d 100644 --- a/composables/useConfig.ts +++ b/composables/useConfig.ts @@ -29,6 +29,7 @@ const defaultConfig: DefaultConfig = { aside: { useLevel: true, collapse: false, + collapseLevel: 1, folderStyle: 'default', }, main: { diff --git a/content/3.api/1.configuration/1.shadcn-docs.md b/content/3.api/1.configuration/1.shadcn-docs.md index 01741106..8bdc737c 100644 --- a/content/3.api/1.configuration/1.shadcn-docs.md +++ b/content/3.api/1.configuration/1.shadcn-docs.md @@ -121,6 +121,9 @@ All configurable icons can be set to iconify icons, emojis and urls, using [smar ::field{name="collapse" type="boolean" defaultValue="false"} Whether to collapse all collapsible by default. :: + ::field{name="collapseLevel" type="number" defaultValue="1"} + Collapse folders that are deeper than the defined level. (Set it to `Infinity` if you want to expand all) + :: ::field{name="folderStyle" type="'default' | 'tree' | 'group'" defaultValue="default"} The default style used for [folders](/getting-started/writing/folders#parameters). :: @@ -232,6 +235,7 @@ const defaultConfig: DefaultConfig = { aside: { useLevel: true, collapse: false, + collapseLevel: 1, folderStyle: 'default', }, main: { diff --git a/types/index.d.ts b/types/index.d.ts index 1dbb1682..8195b70e 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -41,6 +41,7 @@ interface DefaultConfig { aside: { useLevel: boolean; collapse: boolean; + collapseLevel: number; folderStyle: 'default' | 'tree' | 'group'; }; main: {