Skip to content

Commit

Permalink
fix: override configured collase with that defined in _dir
Browse files Browse the repository at this point in the history
Signed-off-by: ZTL-UwU <zhangtianli2006@163.com>
  • Loading branch information
ZTL-UwU committed Nov 5, 2024
1 parent 1b4fd75 commit b2960ba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
10 changes: 9 additions & 1 deletion components/layout/AsideTreeItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,15 @@ const { link, level } = defineProps<{
const { collapse, folderStyle: defaultFolderStyle } = useConfig().value.aside;
const collapsed = useCollapsedMap();
const isOpen = ref(collapsed.value.get(link._path) || (level < 1 && !collapse && !link.collapsed));
const isOpen = ref(collapsed.value.get(link._path) || defaultOpen());
function defaultOpen() {
if (link.collapse !== undefined)
return !link.collapse;
return level < 1 && !collapse;
}
watch(isOpen, (v) => {
collapsed.value.set(link._path, v);
});
Expand Down
3 changes: 2 additions & 1 deletion content/1.getting-started/3.writing/3.folders.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ navBadges:
type: lime
sidebar:
style: group
collapse: false
```
```[Directory structure]
content/
Expand All @@ -38,7 +39,7 @@ content/
::field{name="navBadges" type="[]"}
A list of badges appended to the end of the sidebar link.
::
::field{name="collapsed" type="boolean"}
::field{name="collapse" type="boolean"}
Whether the folder should be collapsed by default.
::
::field{name="sidebar" type="object"}
Expand Down
2 changes: 1 addition & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default defineNuxtConfig({
'badges',
'toc',
'sidebar',
'collapsed',
'collapse',
],
},
experimental: {
Expand Down

0 comments on commit b2960ba

Please sign in to comment.