Skip to content

[hook]: New hook #1230

Open
Open

Description

@anikethsaha

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.

Activity

  1. Koooooo-7 commented on Jun 27, 2020

    @Koooooo-7
    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.

  2. anikethsaha commented on Jun 27, 2020

    @anikethsaha
    MemberAuthor

    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?

  3. Koooooo-7 commented on Jun 27, 2020

    @Koooooo-7
    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.

  4. anikethsaha commented on Jun 27, 2020

    @anikethsaha
    MemberAuthor

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

  5. Koooooo-7 commented on Aug 21, 2020

    @Koooooo-7
    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.

  6. paulhibbitts commented on Aug 31, 2022

    @paulhibbitts
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions