Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to make Obsidian the entire sidebar without requiring a root node. #5

Open
ChildishhAlbino opened this issue Mar 1, 2024 · 7 comments
Labels
enhancement New feature or request

Comments

@ChildishhAlbino
Copy link

ChildishhAlbino commented Mar 1, 2024

Is your feature request related to a problem?

I want to use Obsidian as the entirety of my Astro site, I have been hacking together my own sub-par version of this but want to switch to this ASAP. It is small annoyance that I can't seem to have my obsidian subfolders be the root nodes of the sidebar and must have them nested under a singular root node.

Describe the solution you'd like

A configuration option disableRootNode: true | false to tell the plugin to not generate the subfolders under a root node.

Describe alternatives you've considered

I've tried looking at the obsidianSideBarGroup array but it's empty at the time I can access it before startlight/astro have started up.

Additional Context

Happy to help code this with a pointer or two if you're too busy on more important things. Massive props for making this plugin.

@HiDeoo
Copy link
Owner

HiDeoo commented Mar 9, 2024

Thanks for the feedback, I think this makes sense. Unfortunately, I don't think this is something I can implement at the moment as this would require a change in Starlight.

The current sidebar generation relies on Starlight autogenerated groups which are always a group.
The only possible workaround at the moment would be to duplicate the sidebar generation code from Starlight and manually generating it from the plugin which is not ideal.

I think this is a valid use case that I have already encountered multiple times so I think the best solution would be to open a feature request on the Starlight repository and see if this is something that can be implemented in the future.
I'll keep thinking a bit more about this, list various use cases that could benefit from this and how API-wise this could be supported in Starlight. When I have a clearer idea, I will propose a solution there, and implement it if this is something of interest.

@ChildishhAlbino
Copy link
Author

ChildishhAlbino commented Mar 9, 2024

Hmm - what if the user provided a folder depth underneath the root node to the plugin and then it could run the file tree, work out which folders should be at the "root" and then return back multiple groups for each folder at that depth.

Let's say we have a vault with subfolders A and B then currently the plugin returns the following sidebar configuration:

[
  {
    label: 'Wiki',
    autogenerate: { directory: 'Wiki' }
  }
]

and we get the following sidebar

Wiki
├── A
└── B

If a user supplies sidebarFolderDepth: 1, the plugin could walk down one subfolder and see A and B, returning the following sidebar config:

[
  {
    label: 'A',
    autogenerate: { directory: 'Wiki/a' }
  },
  {
    label: 'B',
    autogenerate: { directory: 'Wiki/b' }
  }
]

and we get the following sidebar

A
└── ...
B
└── ...

Happy to draw a diagram if that isn't clear enough?

@HiDeoo HiDeoo added the enhancement New feature or request label Mar 24, 2024
@nmboris
Copy link

nmboris commented Apr 24, 2024

Couldn't this be achieved simply through configuration?

In my previous attempts, this worked perfectly with both referenced images and internal links. (Of course, you should avoid content pages in the Obsidian root directory as they do not appear in the side menu.)

In the astro.config.mjs I simply referenced the subdirectories of the Obsidian root directory directly and commented out the obsidianSidebarGroup...

SCR-20240424-nmgq SCR-20240424-nnfm SCR-20240424-nmwr

@ChildishhAlbino
Copy link
Author

@nmboris that's a creative way to get around it indeed - let me try that and see the results in my repo :D

@HiDeoo
Copy link
Owner

HiDeoo commented Apr 27, 2024

Couldn't this be achieved simply through configuration?

This is indeed doable through configuration, altho it has several downsides depending on who is in charge of handling the configuration:

  • If it's the user, that means they need to learn about the configuration options and how to use them and manually set them up. It also does not scale well depending on the number of root folders and files.
  • If it's the plugin, this adds more complexity for plugin authors.

Hitting this limitation with multiple plugins is what is making me think that a Starlight solution would be beneficial for everyone.

@ChildishhAlbino
Copy link
Author

If it's the user, that means they need to learn about the configuration options and how to use them and manually set them up. It also does not scale well depending on the number of root folders and files.

Yeah have to agree with this - even trying to maintain this for a few folders was annoying enough so I can't image if I had to maintain more than 5 if it would be worth it - I decided to write my own function that spat out autogenerated group of the subfolders of the root of my vault - works a treat and lets me decorate the titles with emojis which is nice.

Happy to close this issue if you think this is better solved within starlight @HiDeoo

@HiDeoo
Copy link
Owner

HiDeoo commented Apr 27, 2024

Happy to close this issue if you think this is better solved within starlight @HiDeoo

I would prefer to keep it open.

If Starlight implement something to help with this issue, it will be a good reminder to update the plugin and add support for this. If not, it will also be a good reminder that the plugin should be updated to solve this issue as I still think it's a totally valid use-case encountered already a few times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants