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

[hook]: New hook #1230

Open
anikethsaha opened this issue Jun 18, 2020 · 6 comments
Open

[hook]: New hook #1230

anikethsaha opened this issue Jun 18, 2020 · 6 comments

Comments

@anikethsaha
Copy link
Member

Feature request

A new hook to update the content of navbar

What problem does this feature solve?

This will be useful as it will support the creating of dynamic navbars, control over the navbar with just markdown.

What does the proposed API look like?

Ref Poc #1229

How should this be implemented in your opinion?

#1229

Are you willing to work on this yourself?

Yeah, if anyone else wants to pick it feel free to continue

NOTE

This is not the priority as of now. I have opened this just for discussion as we are having some discussion as well for other features.

I would also welcome request for other new hooks as well.

@Koooooo-7
Copy link
Member

nice idea ! user will hv more operability of the nav.
I check it like this, it actually worked.:+1:

 hook.updateNav(function(nav){
       return
           `<a href="#/more-pages?id=more-pages" data-id="more-pages" class="anchor"><span>More pages</span></a>
            <a href="#/quickstart?id=quick-start" data-id="quick-start" class="anchor"><span>Quick start</span></a>`
          }),

image

I wonder if there would hv another solution of those <a> links .
let users put the whole things there like I posted above seems messy .

I prefer to let users just write the relative path like what there do in _navbar.md and we parse the router( not sure whether it is accessible now). maybe there should be an array instead of the long string.

pseudo code

 hook.updateNav(function(nav){
       return
           [ '/more-pages?id=more-pages',
            '/quickstart?id=quick-start']
          }),

besides that, if user wanna the deep level nav, it would be more complicated.

@anikethsaha
Copy link
Member Author

yeah thats a good point, though currently writing markdown relative to root I guess. . , would it make more sense to be relative to _navbar.md?

@Koooooo-7
Copy link
Member

yeah thats a good point, though currently writing markdown relative to root I guess. . , would it make more sense to be relative to _navbar.md?

nah, if the hook were relative to _navbar.md , why not just set in _navbar.md directly. 😅
but it is actually relative to _navbar.md in some way, cuz the hook can provde the context (${nav}), what they set in _navbar.md.

I thought the dynamic nav meant user can change it at each selection/page. therefore , we should expose more context for this hook. unfortunately, we render the nav and content separately. so, I hv no idea about what this hook should be right now.
At least, it has more flexibilities of the nav to users. if possible, we can hv a try for this hook and get the feedback from users.

@anikethsaha
Copy link
Member Author

this is actually a kind of better way for plugins to change the navbar content instead of doing hacky js code.

@Koooooo-7
Copy link
Member

I found that the navbar have the translation issues that it wont be replaced (no options now) when the language changed.
maybe we can use the hook to solve it also.

@paulhibbitts
Copy link
Collaborator

For what it is worth, I'd also be interested in seeing this feature added. I ran across this issue with my Docsify-This.net project and trying to re-write URL links in the Navbar to work with remote Docsify sites. I use hook.afterEach to do this for main Markdown content but discovered no way to do the same with the Navbar.

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

No branches or pull requests

4 participants