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

Sidebar's base need extends parent's base #4114

Open
4 tasks done
Wetoria opened this issue Aug 8, 2024 · 3 comments
Open
4 tasks done

Sidebar's base need extends parent's base #4114

Wetoria opened this issue Aug 8, 2024 · 3 comments

Comments

@Wetoria
Copy link

Wetoria commented Aug 8, 2024

Is your feature request related to a problem? Please describe.

Example like below config of sidebar.

{
  "sidebar": {
    "/zh-Hans/reference/": {
      "base": "/zh-Hans/reference/",
      "items": [
        {
          "text": "社区集市",
          "link": "/",
          "base": "/zh-Hans/reference/bazaar",
          "items": [
            {
              "text": "图标 icon",
              "link": "/icon"
            },
            {
              "text": "插件 plugin",
              "link": "/plugin"
            }
          ]
        },
        {
          "text": "插件 API",
          "link": "/",
          "base": "/zh-Hans/reference/api/plugin",
          "items": [
            {
              "text": "事件总线",
              "link": "/event-bus/"
            },
            {
              "text": "",
              "base": "/class",
              "items": [
                {
                  "text": "Plugin",
                  "link": "/Plugin"
                },
                {
                  "text": "Dialog",
                  "link": "/zh-Hans/reference/api/plugin/class/Dialog"
                }
              ]
            }
          ]
        }
      ]
    }
  }
}

When I set a base value of parent, the child node can jump correct. like icon and plugin in /zh-Hans/reference/bazaar.

But when I use extends value of base, I can not jump to the correct page. like plugin in class.

In order to fix this problem, I need to change /class into /zh-Hans/reference/api/plugin/class.

Fine, I can jump to the page plugin of class correctly.

But it is a terrible thing to write path multi times. In this example, means the part of zh-Hans, reference, api.

This problem can not fix with relative path. When I use ./ or ../ will lead a new problem.

If I am in event-bus now, use relative ./class will check with /zh-Hans/reference/api/plugin/event-bus. Click plugin will get /zh-Hans/reference/api/plugin/event-but/class/plugin.

Describe the solution you'd like

I think base value should extends of parent. Which means the result of "base": "/class" should be added the parent's base or link, like /zh-Hans/reference/api/plugin/class.

Maybe just append the base or link in sidebar.ts#L111 can implement this feature.

Describe alternatives you've considered

No response

Additional context

No response

Validations

@brc-dd
Copy link
Member

brc-dd commented Aug 8, 2024

This was discussed earlier, but it leaves no feasible way to remove parent's base. For example, how would you do this then:

{ text: 'Config & API Reference', base: '/reference/', link: 'site-config' }

image

the last link in above image doesn't share the same base as rest of the group.

@Wetoria
Copy link
Author

Wetoria commented Aug 8, 2024

This was discussed earlier, but it leaves no feasible way to remove parent's base. For example, how would you do this then:

{ text: 'Config & API Reference', base: '/reference/', link: 'site-config' }

image the last link in above image doesn't share the same base as rest of the group.

I'm not sure about all logics. Maybe we can use a path starts without slash? Just like the mode of base + link.

In above example, change './class' to 'class' should be append parent's base?

I notice someway will check http: or https:, so I'm not sure about other problems, If will lead, plz let me know. tks a lot.

@Wetoria
Copy link
Author

Wetoria commented Aug 9, 2024

After my attempts, I found that it is possible to create a soft link in the guide directory by the way of soft link, and it can also jump to the corresponding page

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

No branches or pull requests

2 participants