-
Notifications
You must be signed in to change notification settings - Fork 503
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
Related content experiment #3928
Conversation
@hamishwillee you'll love this. :) |
One thought I had was... With this branch here, we could write something like: if (doc.slug.startsWith("Glossary") {
doc.related_content = getRelatedContent("glossary", doc);
} and then we build a fresh new (in pure Node) custom sidebar for ALL Glossary pages. Perhaps a |
Yes I do love this :-). As an aside, the JSON is still manually crafted. Two things it may be useful to think about at this point
I'm not entirely sure what the proposed glossary thing will look like. It is worth a discussion, but my thinking is that what I might like to see on a glossary is thee sections:
Anyway, this is going to be a much better infrastructure to build on than what we have. Can't wait to play with it. |
One of the key benefits of this is that we can ship a LOT less in the server-side rendered HTML if we know a certain <details open={node.containsActive}>
{(!isServer || node.containsActive) && <ol>...</ol>}
</details> What that means is that the SSR HTML only contains the HTML that is expanded. I tested this; the HTML of the whole The visual difference is none. If you were to consume these pages without JavaScript enabled, (i.e. no React hydration) you wouldn't be able to expand any of the |
@hamishwillee @wbamberg @Elchi3 I need your help. I need your help in shipping this into production. So far this has been a pseudo-experiment and I've chosen to only tackle But I'm running out of time here. I need to focus on the MDN Plus stuff. I don't worry about getting the tests to pass. What I need help with is testing and sanity checking. There's some interesting business logic to discuss too. Look at what I did in Another area where we should discuss is the grabbing of titles for the links. In the old KS sidebars each title is determined by the massive hash table of all tables. See this code for example. |
It's less important but still somewhat important. The build-times are roughly 20% faster now (for the |
@peterbe I finally managed to get this working in a Ubuntu VM but I've run out of time to properly test it due to my "real work". My problem is I'm not 100% sure what I should be seeing vs not seeing. I think this should just be affecting the related topics section of sidebar as injected by It seems to be working fine with most of the same behaviour as the current sidebar - sidebar opens to the current page when you load it. All other trees are closed at this point. Looking at http://localhost:3000/en-US/docs/Learn/Server-side/Express_Nodejs/mongoose#setting_up_the_mongodb_database I do see that the link looks like this - italic and clickable. It is highlighted but I would make it bold and non-clickable for current page. Try it - you'll see that you get taken to the top of the page so the sidebar context is lost. With respect to your discussion about sidebars and business logic, I am not so confident that I can add much useful feedback. But here goes "my 2 bits":
|
"Related topics" is just the headline for all sidebars. |
There are other pages that didn't use |
I don't disagree but it quickly gets hairy to debate that. The Learn sidebar and the MDN sidebar are trivial.
but there are plenty of sidebars that sufficiently complicated that they quickly "outgrow" Yaml. E.g. the clustering by leading character for SVG sidebars. E.g. https://developer.mozilla.org/en-US/docs/Web/SVG/Element/altGlyph |
I don't understand this sentence. |
Thanks, I will test again on Monday. Re "I don't understand this sentence". Yoiks, sorry. All I meant here is that there is work you guys are doing to make sure US doc-version tags and browser-compat keys etc get used in localisations. We wouldn't want all keys to be affected by that change though, if they actually are locale specific. |
@peterbe Thanks for the explanations. I have had a further play. I wouln't say "robustly" but hit various links and open closed pages for 20 mins. It seems very much the same as currently - certainly "no worse". It is hard to say that it is better because I already find it pretty fast and things like a lower transmitted data size don't really affect me for local testing. But a better underlying infrastructure for these things is a win even if it doesn't change much for user facing stuff. Reiterating the problem with link behaviour: italic highlighting is hard to see, particularly if the link is off screen and you're searching for it in a sea of other links. Further, if you click that link the new page is loaded and the link disappears. Unless you add support to scroll to the current sidebar open link, the sidebar link should not be clickable. Essentially though it is no worse from an end user point of view so if no one else runs into problems during testing sounds like a good move. FMI, because this is what I see as the next step ... does the new definition allow us to collapse the top level? Specifically, I want to be able to make that learn sidebar into around 7 top level twisties |
On hold indefinitely |
@dalexsy It's not your place to announce a decision on this and close it. First you need to understand it fully, the reason for it, and then make an argument for why it should be "on hold". This is the first moment I've had a chance to understand this in more detail, and the thing that strikes me is that this is essentially a refactoring (for speed, ease of maintenance, and reliability) of the way we generate sidebars -- simplifying that functionality by moving that functionality out of the macros and into a single function within the builder -- and doesn't preclude any future UX plans around sidebars, but in fact makes them easier to do when that time comes. |
@escattone I disagree with you there. I shared with the rest of the team that I have a plan for how we would restructure the sidebar as part of the redesign, and it was my intention that we would be able to work on this together as a team. My concern is if you all continue working on this now without my input, we're going to have to be redoing work down the line when I do have the capacity to be involved. |
@escattone: taking this conversation to a private thread with everyone involved. This type of conversation on a public repo can only confuse the community and hurt the team - i would appreciate if you could avoid it in the future. Also, even if this is now reopened, please put on hold any work on it until we have clarified things. |
Early days!
What this does is that it moves from a
kumascript/macros/*.ejs
to abuild/related-content/*.js
file.Basically, instead of a EJS macro that generates a blob of HTML, it's a plain Node function that generates an array. The array is meant to be "infinitely recursive". But it basically looks like this:
The killer feature of this is that on the React side, the HTML that is generated is done in a way that it automatically expanded the
<details>
tags based on the current page you're on might be inside its<details><ol>
tag. All others are closed.The other big difference is that Node is easier to debug and reason about. E.g. debugging. ...than KS EJS files.
Since the
sidebarHTML
can get large and that it needs to be encoded as a serialized JSON string too, for hydration, we stand to make the sidebar payload much smaller. For server-side rendering, we only need to render the HTML elements that will be visible. E.g. the CSS sidebars are ~70KB of HTML, but if you delete all the HTML that you can't see anyway, the size becomes 5KB. The list of URLs and titles aren't going away but the SSR HTML will be potentially much smaller.In summary
The benefits of this are: