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

Support specifying short-titles for the sidebar from content pages? #1821

Open
Jacco-V opened this issue Jun 17, 2022 · 3 comments
Open

Support specifying short-titles for the sidebar from content pages? #1821

Jacco-V opened this issue Jun 17, 2022 · 3 comments

Comments

@Jacco-V
Copy link

Jacco-V commented Jun 17, 2022

Feature request

What problem does this feature solve?

This feature would allow long titles for the documentation headers, with short titles in the sidebar, when needed. Right now, this can be done by manually creating each and every entry for the sidebar, but this:

a) takes a lot of time,
b) is very prone to errors, and
c) forces you to write each and every sidebar entry yourself, even if short-titles are only required for a couple of entries.

What does the proposed API look like?

How should this be implemented in your opinion?

Right now, Docsify supports Customise ID for headings. It would be great if it would also support something like:

## How would I write a "hello, world" example? :sidebar="hello world?"

image

Are you willing to work on this yourself?

Willing? yes, but realistically, I don't now how to do frontend development.

Relation to other issues?

This issue has of course some relation to Proposal: auto generate sidebar but as far as I can see the two are not the same, and I suspect the difficulties that would be part auto-generating the entire sidebar do not apply to only generating the in-page links(?)

@Jacco-V
Copy link
Author

Jacco-V commented Jun 18, 2022

I would be willing to try and implement this, but I have not idea where to start?

@julienw
Copy link
Contributor

julienw commented Jun 22, 2022

My understanding is that the title is generated here:

const nextToc = { level, title: removeAtag(str) };

As you see it's taken from str quite directly. But you'd like that it's taken from the config object instead.

Maybe you can try doing something like this in line 238:

const slug = slugify(config.id || str);
const url = router.toURL(router.getCurrentPath(), { id: slug });
nextToc.slug = url;
_self.toc.push(nextToc);

and add:

if (config.sidebar) {
  nextToc.title = config.sidebar;
}

@Jacco-V
Copy link
Author

Jacco-V commented Jun 22, 2022

Please see PR #1825

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