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
Navmap feature for nested navigation #81
Conversation
Navmap will allow nested navigation for pages. To * add a page to navmap, you've to add `{:navmap? true}` to pages meta. * define navigation hierarchy you can use directory-structure (first level will be in /pages/nav1.md, second level will be in /pages/nav1/nav11.md) * use navmap, you can * access navmap-pages (sequence of pages) in your template, same as you've used navbar-pages and * access navigation childs as :navmap-children in specific pages (eg. nav1 will contain a sequence of one page representing nav11).
Is this PR in working order? I noticed you opened it but added some more commits afterwards. |
Yes it is. After my initial pull request I found it useful to add a sort-by :page-index. So order of entries now depends on their :page-index instead of path. You will find a test, that should explain the function. If you like this feature, I will add documentation also. |
Awesome, I'll take a look soon :) |
It's not clear to me what behaviour you're expecting when you say this PR is supposed to allow for nested navigation in pages. I installed your PR locally and with the I also don't think it's necessary to add the [{:page-index 1
:title "Page 1"
:uri "pages/page1"
:prev nil
:next {:title "Navmap 1", :uri "/pages/nav1"}}
{:navmap? true
:page-index 2
:title "Navmap 1"
:uri "/pages/nav1"
:navmap-children [{:navmap? true
:title "Navmap 11"
:uri "/pages/nav1/nav11"
:page-index 1
:navmap-children [...]
:prev {:title "Navmap 1", :uri "/pages/nav1"}
:next { first item in children }}
{:title "Navmap 12"
:uri "/pages/nav1/nav12"
:page-index 2
:prev { last item in previous page's children }
:next {:title "Page 2" :uri "pages/page2"}}]
:prev {:title "Page 1", :uri "/pages/page1"}
:next {:title "Navmap 11" :uri "pages/nav1/nav11"}}
{:page-index 3
:title "Page 2"
:uri "/pages/page2"
:prev {:title "Navmap 12" :uri "pages/nav1/nav12"}
:next nil}] The prev/next links don't necessarily have to work like a DFS, that was just the best model I could think of at the moment. If you have a better idea then I'm open to suggestions. By including the page tree in one of the sidebar/navbar vectors like this, the trees can be interposed between "normal" pages and users can choose to display only the top level link or the children as well. |
Hi, thanks for having a review on my pull request and sorry that I missed some things ...
I will add a usage example in your documentation project, so it's getting more clear, I hope. Planned to do this next week ...
I will have a look on this. You're right, I'm using
I've chosen the navmap parameter in order to keep backward compatibility. But I can imagine, that an additional edn parameter will work as well. At the moment navbar and sidebar vectors are working globally flat - am I right?
What does DFS mean?
If you talk about including sidebar-pages vector on page level (instead of global compiler-level like it's right now), yes. I've already though about that. But at the moment I do not need sidebars. So in terms of YAGNI (you ain't gonna need it) I've not touched sidebar-pages. |
Instead of having
If I'm correct in my assumption of what you mean by "globally flat" then yes, the navbar and sidebar vectors don't have any nesting to them at the moment.
Backward compatibility can be kept without the
DFS means depth first search. It's a tree traversal algorithm.
I think there's some confusion here. I'm talking about including navmap trees in the already existing
Instead of having just
and "Navmap 1" off somewhere else because it's not included in By "users can choose to display only the top level link or the children as well" I mean that with this implementation users can choose to show
|
Hi, sorry for the long delay ... there is a huge bunch of work on my desk. Regarding the clean-urls issue I will implement a test and fix. Regarding not introducing additional navmap-pages I agree - a less redundant solution would be better for sure :-). We've
With the current implementation following example (lets assume, each page contains
will result in
This behavior we should not break, because someones site will probably relay on this. But instead of having a parallel structure like navbar & navmap we can also introduce a configuration, toggling between flat and hierarchic navbar vector - as u suggested. In this case we would have
What do you think about? Best regards, |
Just to be clear, by a hierarchical model you mean
and a flat model would be
? If so then I think this implementation sounds good. |
exact ... so I will go ahead and come back with a solution :-) |
Conflicts: project.clj src/cryogen_core/compiler.clj
parameter to config
Hi, I think, I've now a working solution. In short, we've:
I've also a templating Example (works on bootstrap-4):
For me it works now with unclean urls also. What do you think? BR, jerger |
Thanks, I'll take a look in the next couple of days when I find some time. :) |
As the hole-problem comes from upfront dividing the nested structure into But there remain some questions:
In Terms of template I need nested top-level navigation and sidebar-navigation in addition. So I have to some kind of For top level navigation it may look like:
For sidebar this can be:
I would appreciate to implement these filters also in cryogene-core because it's likely that many people will need this filters. Is it possible to add filters on cryogen-core level? What do you think about? If you will accept such a solution I will go to refactor :-) |
I would recommend to simply use <ul>
{% for page in pages %}
<li>
<a href="{{page.uri}}">{{page.title}}</a>
</li>
{% endfor %}
</ul> You simply don't filter the pages in that case and everything is assumed to be top level. For the hierarchic mode, I think that adding filters for navbar/sidebar would be sensible. It makes the template code more explicit about what it's doing. |
On a greenfield I would appreciate just having The only argument against is backward compatibility. If we introduce Should I really break compatibility? |
I don't think it's as much of a concern for existing users. If I already have my site working the way I like, usually I just keep it on the version of the engine I was using. I think it would be reasonable to add a |
That's fine, users can filter their pages on their own terms. |
Okay, great - I will start refactoring :-) |
Okay, I've refactored and tested with my websites ... here the result is: New FeaturesSupport of hierarchic menus & page structures:
Breaking ChangesPages is replacing no longer supported navbar-pages / sidebar-pages. In order to realize navbar / sidebar functionality, you've now to write filters. ExamplesI've also a templating Example for navigation (works on bootstrap-4):
and a template example using children as sidebar pages:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With :page-model
set to :hierarchic
:
- If
:page-root-uri
is empty then:pages
is empty - If i have
/1.md
/2.md
/2/22.md
then in the :pages
output I get page 1 with 22 as a child as well as page 2 with 22 as a child. Only page 2 should have 22 as a child.
Okay ...
|
I've a public example here: https://github.com/DomainDrivenArchitecture/LearningCryogeneGen/invitations - with your described scenario working. Tomorrow I will take a close look at your example in order to find the relevant diff ... |
okay got it. your pages are:
which results in
So that's seems to be okay to me? |
Ah my mistake, it's hard to parse all that text. That's fine then. I'll take a look at your fix for the first issue. |
In order to debug your case - can u provide the pages & config.edn to me? You can overwrite my example - I invited you as contributor here: https://github.com/DomainDrivenArchitecture/LearningCryogeneGen/invitations - but providing an archive of your pages is also fine to me ... |
I said my setup is the same as before. Just refer to my previous comment. |
tried out your layout here: https://github.com/DomainDrivenArchitecture/LearningCryogeneGen For me this works , so I can not reproduce your error. |
How will you go on with this pull request? I can not reproduce your issue ... so I've no idea what can be the next step ... |
We seem to have hierarchical pages now, I use it in 0.1.64 (example). Is there some element of this ticket that isn't covered? Forgive my lack of deep comprehension of this thread; I read it a while back, around 0.1.60. I can invest the time to understand if there's something to do in addition to what's been done--I see other seemingly stale tickets. |
I don't think so, new tickets can be opened if there's something lacking. |
is there some doc how this works now? |
Navmap will allow nested navigation for pages. To
{:navmap? true}
to pages meta.level will be in /pages/nav1.md, second level will be in
/pages/nav1/nav11.md)
you've used navbar-pages and
nav1 will contain a sequence of one page representing nav11).