-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
CodeGroup rendering tabs and CodeBlock on hard reload #2711
Comments
I hope to get to this in the next few days |
#2686 to reproduce the problem and get no reply.
|
I believe I just need to move this component to only be rendered on the client |
vuepress build does not prerender code-blocks correctly. fixed by surrounding it with a ClientOnly block to force it to be rendered dynamically. See vuejs/vuepress#2711 fix #4
Hi @d-pollard I see the source of the ClientOnly component is: export default {
functional: true,
render (h, { parent, children }) {
if (parent._isMounted) {
return children
} else {
parent.$once('hook:mounted', () => {
parent.$forceUpdate()
})
}
}
} I am thinking of editing the CodeGroup component to hook this same functionality in. If you confirm or let me know the best way to fix it, I'm happy to submit a pull request as well. |
I'll take a look at this in the next few days, I appreciate all the feedback! |
Thank you @d-pollard. Here to help as you need. |
Screen.Recording.2021-02-09.at.7.15.10.PM.movExample of the issue + the fix |
Hello @d-pollard ,Test the site https://qcyblm.github.io/vuepress-CodeGroup/, |
@qcyblm it looks good for me, it renders the code block |
Screen_Recording_20210209-230334_Firefox.mp4@qcyblm it shows this for me |
In chrome I get this too CodeBlock can't be rendered locally, can you fix it? Source: https://github.com/qcyblm/vuepress-CodeGroup The procedure: yarn && yarn dev |
@qcyblm - thanks for the clarification; I was able to debug and fix the issue you're seeing. Mind pulling down my recent changes and verifying that they work for you? |
Yes, and verify that they work for me. |
@d-pollard - You can clone the vuepress-CodeGroup to make changes and pull requests to me, I do local testing. |
I had the same issues as @qcyblm, but saw your changes right after I commented, so I deleted my comment and checked again. It works beautifully now, thank you! |
Sweet; okay I'll work on getting this merged in the AM (it's 1:00AM here lol I'm tired) Have a good day/night everyone! |
My region is in China (it's 1:58 PM) |
…2794) * fix($core): wrap code group in ClientOnly * fix($core): component CodeGroup loads correctly on client * fix($core): component CodeGroup loads correctly on client * fix($core): activate codetabs whenever we update the arr
Should be fixed as of https://github.com/vuejs/vuepress/releases/tag/v1.8.1 |
Once [this issue]( vuejs/vuepress#2711) with VuePress is fixed, we might be able to use the prettier code-groups again :-)
* Add code-switcher vuepress plugin * Create POC of code-switcher plugin usage * Remove code-switcher plugin, add copy-code plugin - code-switcher plugin is not compatible with screenshots inside "tabs". - copy-code plugin is ready to be used but not configured yet * Update integration links to form a 3x3 flex layout * Add first version of Quick Start Guide rewrite * Step 1 (installation) is written for both paths * Steps 2 & 3 are just outlines for now * Current Quick Start Guide file has not been deleted yet, but renamed * Added first screenshots * Add meta tags * Add first version of Step 2 for Starters path * Remove unnecessary edit icon screenshot * Customize CSS * 💄 Lint & reword parts of the Starters path * Add first version of Step 2 for Hands-on path * Restore integration links look * Delete old quick start guide files and create a 3-step, 3-file QSG * Update frontmatter title of some files for proper "next/prev" buttons * Use 'Content-Types Builder' in all dev docs for consistency * Update wording for consuming API intro in hands-on path * WIP: Create IntegrationLinksAlt for an alternate look * Improve draft * Fix some formatting * Reword some parts * Add a few links * Improve CSS for InstallLinkAlt components * Update wording & links in integration guides * Add link to starters in step 3 for starters path * Rename quick-start-step1.md back to quick-start.md to avoid breaking links * Fix sidebar links to consider quick-start-step1 file renaming * Group the 3 steps back into a unique file * Highlight path buttons & create new Requirements style * Delete intermediate congrats * Add more margin below new Requirements block * Replace NPX by NPM in code group titles * Title case UI elements * Add more margin above path buttons * Fix links to quick start guide featured in integrations guide * Rework steps 1 & 2 of Starters path * Fix step 2 links in integration guides * Fix misnaming Step vs. Part * Rework Step 3 of starters path * Add more CSS customizations * Rework introduction * Rework part 1 of Starters path * Rework part 2 of Starters path * Rework part 3 of Starters path * Slightly reword congratulations conclusion of Starters path * Add consistency to step naming * Replace Slack by Discord * Rework Hands-on path * Rename image files (step → part) * Update images * Improve again Starters path * Improve again Hands-on path * Experiment with alternate callout styles * Fix missing uppercase * Fine-tune CSS * Tone down "congrats" callouts * Add "use your API" as a final step * Simplify "To go further" sections * Include going to the UI section as a first step in procedures * 💄 Clean up CSS * 💄 Lint * Adjust viewbox of some integration guide logos so they fit better * Update wording and link for intro of integration guides * Restore meta-title for FAQ * Fix wrong file for Permissions screenshot * Be more explicit in tip about server not running * Add link to Gatsby blog starter * Switch order for npm / yarn * Remove mention of creating your own category from the CM Because you can actually can't 🤷 * Remove emoji in 'Choose an author and a category…' paragraph * Fix (again 😅) wrong screenshot for Users & Permissions * Fix "Draft" not being a button * Fix bullet points & structure in requirements Co-authored-by: meganelacheny <megane.lacheny@strapi.io> * Enhance sentence about using Gatsby starter Co-authored-by: meganelacheny <megane.lacheny@strapi.io> * Remove '+' from button names * Replace 'dialog' by 'window' * Improve sentence about being prompted for 'Quick Start' in terminal * Replace 'left-hand menu' with 'main navigation' * Update wording: frontend → front end, backend → back end * Rename Parts A, B… instead of 1, 2… To avoid confusion between parts and steps. * Use hyphenated 'front-end' and 'back-end' when appropriate See https://css-tricks.com/poll-results-front-end-front-end/ * Update formatting + add many-to-many icon * Remove capitalization for "admin panel" * Replace "dropdown" with "drop-down list" * Improve Starters path * Add @vuepress/back-to-top plugin https://v1.vuepress.vuejs.org/plugin/official/plugin-back-to-top.html As a solution to a suggestion from Maeva. * Improve Hands-on path * Update path buttons design * Update InstallLinkAlt button design * Fix InstallLinkAlt button border * 💄 Add some tiny improvements * temp fix for vercel * temp fix for vercel patch 2 * Fix code groups not rendering properly * Embed code-groups in <ClientOnly> component Not rendering code-blocks seems to be a SSR issue. Using [`ClientOnly`](https://vuepress.vuejs.org/guide/using-vue.html#browser-api-access-restrictions) could force render the embedded components on the client and possibly fix it. * Update Nuxt logo * Adapt to latest Gatsby starter release * Switch to card-style tabs to prevent SSR rendering issues of code-groups Once [this issue]( vuejs/vuepress#2711) with VuePress is fixed, we might be able to use the prettier code-groups again :-) * Center Next.js logo * Replace "requirements" by "prerequisites" * Remove unnecessary occurences of "just" It would imply that it's easy, and this is something to avoid in the documentation :-) * Tinker with SVG logo attributes to better align them * Reduce Ruby + Flutter logo sizes * Reverting temp fix for Vercel preview Co-authored-by: meganelacheny <megane.lacheny@strapi.io> Co-authored-by: Derrick Mehaffy <derrickmehaffy@gmail.com>
Bug report
Steps to reproduce
Visit a VuePress docs pages that renders multiple CodeBlocks in a CodeGroup, e.g. https://mubanjs.github.io/muban/guide/#installing
What is expected?
The tabs showing up, and the first tab showing highlighted code.
What is actually happening?
No tabs showing (although the space is there), and instead a highlighted message:
// Make sure to add code blocks to your code group
Other relevant information
When navigating to another page and back, the CodeGroup displays correctly.
It seems like it's some kind of re-hydration issue when using the rendered HTML.
It also seems to not happen locally.
npx vuepress info
in my VuePress project:The text was updated successfully, but these errors were encountered: