How to get a list of all pages (title, path, children) #1601
-
Hi there, I try to migrate a vuepress v1 site to the new structure. I wrote a custom component there that automatically generated a menu structure of multiple (sub)pages in the sidebar. This was done with the use of the 'pages' variable available through 'site' (see snippet below).
Currently I'm migrating to the v2. There we have the "useSidebarItems". I have overwritten this file by using the new alias feature as follows:
So far so good :) Now I want to access the App.pages variable from there, so that I can render the right parent/child page urls dynamically based on the pages available. But I don't know how the App.pages can be made available there. I have found a couple of threads (#380, #72). But the "usePagesData" doesn't seem to be available (anymore)? Any other good suggestions are more then welcome. The main goal is to fill the "sidebar" variable (defined in config.ts) dynamically based on the pages available. To give an idea of what I want to achieve, the (partial) old sidebar config looked as follows:
What it then did was displaying on the "/SomethingNew/" (and all subpages) the menu structure of the page "SomethingNew" and all child pages up to a depth of 2 folders deep. When on "/SomethingElse/" (or any subpage) it displayed the "SomethingElse" structure with "Something Else" and then all children from "/SomethingElse/Folder2/FolderMore/" up to 5 folder levels deep. Basically what I need is a point in the vuepress application (let it be a plugin or some lower level script) where I can have access to the theme.sidebar variable and the app.pages variable and where I then can ideally modify either the sidebar layout or overwrite the theme.sidebar variable :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Try to see how theme hope achieves structure sidebar |
Beta Was this translation helpful? Give feedback.
Try to see how theme hope achieves structure sidebar