-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
upgrade to docusaurus-v2 #233
Conversation
Hi @sw-yx @yangshun @wgao19, I think it's not far to be complete. Will look to find the last details. => https://deploy-preview-233--react-typescript-cheatsheet.netlify.app/ There are probably a few choices to be made regarding the new features of v2, like:
I think the user showcase page is quite useless for this project, do you plan to use it? Also, there was a "star" button in the footer before, it used a script inserted in the body using data-attributes. I wasn't able to migrate it easily as React overrides the star button on hydration. Putting it back would probably require to override the default Docusaurus Footer. |
We could add this do D2.
Not sure exactly what you mean here. We collapse non-active categories by default on initial load. We recently added a feature to allow expanded categories by default so the UX of the sidebar changes. We no longer collapse categories which have been expanded while browsing the docs
Plenty of Docusaurus v1 sites do this. It's possible to still achieve this via the HTML option in the footer. But our recommendation would be to move it into the hero of the landing page and keeping the footer simple. |
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.
Thank you for this @slorber! Looks great in general!
website/docusaurus.config.js
Outdated
/* | ||
{ | ||
label: "Star", | ||
class: "footer__link-item github-button", |
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.
We didn't document the footer well, but you could do this for the GitHub star button instead - https://github.com/facebook/docusaurus/blob/master/website/docusaurus.config.js#L194-L197
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.
this would be nice! not sure where to pull it from but can investigate later
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.
Replay
@slorber looks great so far! @ me if you need anything from me in particular! yes showing the star would be nice but it can be a separate issue if we cant figure it out easily |
Hey @sw-yx , the workaround suggested by @yangshun worked to add the star button in the footer. It only works in prod mode though, I don't think it's a big deal. I tried to put this button in the body, using the react wrapper the lib suggested (https://buttons.github.io/), but encountered an issue with the theme not properly applied, and wasn't sure exactly where to put this button on the home page, so for now let's keep it in the footer. More details: buttons/react-github-btn#7 (comment) So, I think everything works fine except the inline code blocks in MDX / JSX fragments here: Don't know yet how to solve this :/ |
@yangshun unfortunately I tried both options and it didn't work. I don't see any way to solve this in userland. Will try to come up with a solution. Not sure I could support `` but I'll try to find a solution. |
Yeah that's what I meant by "somewhat readable". I think it's still better than the current one. |
@yangshun I'm able to make the const InlineCodeBlock = (props) => <code>{props.children}</code>;
export default {
code: (props) => {
const { children } = props;
if (typeof children === 'string') {
return <CodeBlock {...props} />;
}
return children;
},
summary: (props) => (
<MDXProvider components={{ code: InlineCodeBlock }}>
<summary>{props.children}</summary>
</MDXProvider>
),
...otherComps,
}; Do you think we should add that? That wouldn't allow the markdown syntax in summary (asked about it here: mdx-js/mdx#628 (comment)) But at least, we can add inline code blocks in a summary Another option could to have export default {
code: (props) => {
const {children, inline} = props;
if (typeof children === 'string') {
if ( inline ) {
return <code>{children}</code>
}
else {
return <CodeBlock {...props} />;
}
}
return children;
},
}; I think we could document the |
…lock instead of the prism editor context: typescript-cheatsheets/react#233 (comment)
Hi @sw-yx I've made a PR so that it's possible to use inline code tags in summaries: facebook/docusaurus#2868 As this is a temporary feature until MDX 2 supports proper markdown interleaving, not sure this will be approved. As this code in summary thing is only used in 3 places, does it matter to you to remove it? This code in summary appears in 2 docs:
edit: actually likely to be merged here: facebook/docusaurus#2857 Do you see other things I should change, or is this the last item to fix? |
@slorber of course we are going to merge this PR! 😅 I glanced through and I'm fine to remove it. Still feel like Docusaurus should do its best to honor Github Flavored Markdown though. The footer looks a bit weird... did we decide what to do here? apart from that everything is looking really good here! site feels fast and is well structured and I am LOVING the dark mode. |
Sure we are going to merge this one :) I was talking about a Docusaurus PR here, that actually got closed for a better one that will solve the code tag in summary issue (see) on next release. But you'll have to use Great to see you like D2 About the footer, to me it looks similar, you don't get the star button hydrated properly on last version? D1: D2: |
Ohhh, on navigate the Star button gets reset by React as it's now a SPA... :( @yangshun do you have an example D2 site where there is a star button like that by chance? In the footer? @sw-yx would you be ok to put this Star button somewhere else, as @yangshun suggested to keep the footer simple? The basic D2 footer is only a list of links ordered by columns. We can override it with a custom React component (theme swizzling / shadowing), but that means more long-term maintenance on your side. |
@sw-yx one solution would be to use a CSS-only github button. The D1 lib was some global JS script that looked for a link with some specific data attributes, and the fact it's global script only run at mount time does not play well with an SPA. What about using this one instead? http://necolas.github.io/css3-github-buttons/ The drawback of CSS only is that you don't have the current number of stars Another possibility seems to do what @yangshun mentioned and use a "badge" that will draw the github button as an image/svg on the server, querying for a star count: There are multiple options: https://github.com/Naereen/badges#github-stars Just deployed that, is it ok for you? |
awesome :) just need to think to upgrade in a few days after alpha.57 release with the fix for the summary/code thing ;) |
yup, no problem with that. i just like shipping things as soon as they're mostly ready :) can always bump things after |
WIP #234