Skip to content

Commit

Permalink
feat: collapseLevel config
Browse files Browse the repository at this point in the history
Signed-off-by: ZTL-UwU <[email protected]>
  • Loading branch information
ZTL-UwU committed Nov 5, 2024
1 parent b2960ba commit e018fac
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default defineAppConfig({
aside: {
useLevel: true,
collapse: false,
collapseLevel: 1,
folderStyle: 'default',
},
main: {
Expand Down
4 changes: 2 additions & 2 deletions components/layout/AsideTreeItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -94,7 +94,7 @@ function defaultOpen() {
if (link.collapse !== undefined)
return !link.collapse;
return level < 1 && !collapse;
return level < collapseLevel && !collapse;
}
watch(isOpen, (v) => {
Expand Down
1 change: 1 addition & 0 deletions composables/useConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const defaultConfig: DefaultConfig = {
aside: {
useLevel: true,
collapse: false,
collapseLevel: 1,
folderStyle: 'default',
},
main: {
Expand Down
4 changes: 4 additions & 0 deletions content/3.api/1.configuration/1.shadcn-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
::
Expand Down Expand Up @@ -232,6 +235,7 @@ const defaultConfig: DefaultConfig = {
aside: {
useLevel: true,
collapse: false,
collapseLevel: 1,
folderStyle: 'default',
},
main: {
Expand Down
1 change: 1 addition & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ interface DefaultConfig {
aside: {
useLevel: boolean;
collapse: boolean;
collapseLevel: number;
folderStyle: 'default' | 'tree' | 'group';
};
main: {
Expand Down

0 comments on commit e018fac

Please sign in to comment.