docus icon indicating copy to clipboard operation
docus copied to clipboard

[Bug] ButtonLink component doesn't "see" navigation.redirect

Open arkhaiel opened this issue 3 years ago • 4 comments

See https://github.com/mathieunicolas/docus-issue for the code.

The only thing I modified is the aside level : docus.aside.level: 1 I just wanted to use a button-link on the main page to the root of a subfolder (same as if I clicked on the top navbar), but it looks like there's something I don't understand

The problem

I run npm run dev:

  • test-a top navbar : all is ok
  • test-b top navbar : all is ok
  • test-c top navbar : redirected to test-a (priority to navigation.redirect over redirect)
  • test-a button-link : the test-a index (no redirection)
  • test-b button-link : all is ok
  • test-c button-link: redirected to test-b (priority to redirect over navigation.redirect

Now I run npm run generate and I upload the output to netlify : https://visionary-rugelach-3018e9.netlify.app/ The behaviour is different :

  • test-a top navbar : all is ok
  • test-b top navbar : 404
  • test-c top navbar : redirected to test-a
  • test-a button-link : the test-a index (no redirection)
  • test-b button-link : 404
  • test-c button-link: 404

The structure

Here is my content folder structure :

.
├── 0.index.md
├── 1.test-a
│   ├── 0.index.md
│   └── 1.redirected.md
├── 2.test-b
│   ├── 0.index.md
│   └── 1.redirected.md
└── 3.test-c
    ├── 0.index.md
    └── 1.redirected.md

in the root 0.index.md, there's 3 button-link:

:button-link[test-a]{href="/test-a" style="margin: 1rem;"}
:button-link[test-b]{href="/test-b" style="margin: 1rem;"}
:button-link[test-c]{href="/test-c" style="margin: 1rem;"}

In /1.test-a/0.index.md :

---
navigation.redirect: /test-a/redirected
---
# test-a welcome

In /2.test-b/0.index.md :

---
redirect: /test-b/redirected
---
# test-b welcome

In /3.test-c/0.index.md :

---
navigation.redirect: /test-a/redirected
redirect: /test-b/redirected
---
# test-c welcome

arkhaiel avatar Jan 03 '23 04:01 arkhaiel

I updated my issue, I'm sorry I didn't take the time to explain as I should have to in the first draft.

arkhaiel avatar Jan 06 '23 22:01 arkhaiel

@farnabaz any idea about this one?

I need to dig into it, but it seem to be related to Content?

Tahul avatar May 17 '23 13:05 Tahul

I agree that there is a bit of ambiguity and conflict between redirect and navigation.redirect

  • redirect uses when user navigates to the page
  • navigation.redirect uses to determine nav item link

So in test-c:

  • inside nav bar the link will use navigation.redirect and it will not care about redirect
  • inside button, when user hit the button, it will directly go to test-c then in the page it will use redirect and will not care about navigation.redirect

Let's discuss about the perfect behaviour and combination of these two before changing anything.

WDYT @Tahul ?

farnabaz avatar May 23 '23 11:05 farnabaz

I don't know if I can help, but my usecase is simple : with Docus I make a website I use with my students. At the beginning of each hour, they go the the website, then click on their class, and I'd like to define a redirect from the index of their class to the "page of the day", redirect I could update each week. And some students click on the top navbar, some students click on the CTA of the first page BlockHero. That's how I noticed the differences

That's why I also want to be able to collapse all the nodes in the asideTree except the one that contains the page of the day. That's why I also made an issue related to useDocus(), that may overwrite the collapsed state of the asideTree nodes.

Let me know if I can help more !

arkhaiel avatar May 24 '23 01:05 arkhaiel