Skip to content

Prev/Next link text in sidebar config #1373

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

Closed
4 tasks done
davidjr82 opened this issue Sep 20, 2022 · 4 comments
Closed
4 tasks done

Prev/Next link text in sidebar config #1373

davidjr82 opened this issue Sep 20, 2022 · 4 comments
Labels
theme Related to the theme

Comments

@davidjr82
Copy link

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

When the next/prev link text is generated, it takes the text from the frontmatter of the current page you are seeing. If empty, the text will be inferred from the sidebar config.

When inferred from sidebar, sometimes is weird. For example, in the vitepress api docs the "Next" text is "Introduction", and for me it should be "Themes - Introduction" (what if I have 3 sections with the introduction title?).

When using frontmatter, I can change the text in the guide/api page, but this means that if I add new documentation after the api page, the next text in the api page will be wrong.

Problem: In my opinion, the Next/Prev link should be defined in the same page (in this example, in the themes/introduction page), or in the same line as a new option in config.js for the themes/introduction page.

Describe the solution you'd like

Add nextPrevText property in sidebar items in config.js file, as follows:

        sidebar: [
            {
                text: 'Theme',
                items: [
                    { text: 'Introduction', link: '/theme/', nextPrevText: 'Theme - Introduction' },
                ]
            },

and change the priority of rendering the NextPrev text to the following:

  1. frontmatter of current page
  2. sidebar nextPrevText config of the next/prev page
  3. inferred from sidebar config

Describe alternatives you've considered

Add nextPrevText in the frontmatter of the page I am going to go.

Additional context

https://vitepress.vuejs.org/guide/api

imagen

Validations

@brc-dd brc-dd closed this as completed Sep 20, 2022
@brc-dd brc-dd reopened this Sep 20, 2022
@davidjr82
Copy link
Author

@brc-dd
This is exactly the problem I was describing. Here you can customize the text in the page you are coming from, not in the page you are going to. The reasons why I think that is not good were in my first post.

@brc-dd
Copy link
Member

brc-dd commented Sep 20, 2022

Yeah sorry about that. I hadn't read it properly. But currently we don't have any mechanism to access page data (including frontmatter) of a different (previous/next) page. Stuff might get complex while adding this functionality. Also, I don't think there will be a huge number of such pages where you'll need to customize that. I understand that it won't be best DX to keep track of these things, but IG current solution is usable.

@brc-dd brc-dd added enhancement theme Related to the theme labels Sep 20, 2022
@davidjr82
Copy link
Author

davidjr82 commented Sep 20, 2022

Yes, I thought the same about adding frontmatter to the destination page.

But what about adding to config.js sidebar object? I don't know how it works, but if right now it is using the config.js to guess the sidebar, it should not be that difficult to add the text in the destination, since right now the building process is reading the title text of the destination to do it.

It should be as simple as get other property (nextPrevText in my example) if present instead of the title property, isn't it?

@brc-dd
Copy link
Member

brc-dd commented Sep 20, 2022

Yeah using sidebar config it can be done IG. This most likely will be used only when context (sidebar group) is changed. So we can probably introduce some property there and modify our composable.

@github-actions github-actions bot added the stale label Aug 3, 2023
@brc-dd brc-dd removed the stale label Aug 4, 2023
@brc-dd brc-dd closed this as completed in 09a4fdc Aug 4, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
theme Related to the theme
Projects
None yet
Development

No branches or pull requests

2 participants