Skip to content
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

Closed
1 task done
ThaNarie opened this issue Nov 18, 2020 · 21 comments
Closed
1 task done

CodeGroup rendering tabs and CodeBlock on hard reload #2711

ThaNarie opened this issue Nov 18, 2020 · 21 comments
Assignees
Labels
has PR Has a related PR

Comments

@ThaNarie
Copy link

  • I confirm that this is an issue rather than a question.

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.

  • Output of npx vuepress info in my VuePress project:
Environment Info:

  System:
    OS: macOS 10.15.6
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
  Binaries:
    Node: 12.13.1 - ~/.nvm/versions/node/v12.13.1/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.12.1 - ~/.nvm/versions/node/v12.13.1/bin/npm
  Browsers:
    Chrome: 86.0.4240.198
    Edge: Not Found
    Firefox: 81.0.2
    Safari: 13.1.2
  npmPackages:
    @vuepress/core:  1.7.1 
    @vuepress/theme-default:  1.7.1 
    vuepress: ^1.7.1 => 1.7.1 
  npmGlobalPackages:
    vuepress: Not Found
@d-pollard
Copy link
Collaborator

I hope to get to this in the next few days

@qcyblm
Copy link

qcyblm commented Nov 20, 2020

#2686 to reproduce the problem and get no reply.
I've solved this problem and need to manually add CodeGroup and CodeBlock to the global component:

// .vuepress/enhanceApp.js
import Vue from 'vue'
import CodeBlock from "@theme/global-components/CodeBlock.vue"
import CodeGroup from "@theme/global-components/CodeGroup.vue"
// Register the Vue global component
Vue.component(CodeBlock)
Vue.component(CodeGroup)

@d-pollard
Copy link
Collaborator

I believe I just need to move this component to only be rendered on the client

TimoBechtel added a commit to TimoBechtel/socketdb that referenced this issue Jan 11, 2021
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
@thecoden
Copy link

thecoden commented Feb 9, 2021

Hi @d-pollard
I am experiencing this issue as well, but am not familiar with the best way to move the component to client only. I tried doing something similar to @TimoBechtel fix on the docs, but that is not working for me so I believe the component needs to be modified.

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.

@d-pollard
Copy link
Collaborator

I'll take a look at this in the next few days, I appreciate all the feedback!

@thecoden
Copy link

thecoden commented Feb 9, 2021

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.

@d-pollard
Copy link
Collaborator

@thecoden - mind giving this PR a check to ensure it fixes your use-case? #2794

@d-pollard
Copy link
Collaborator

@qcyblm if you could make sure that PR fixes it for you too, I would greatly appreciate it! #2794

@d-pollard
Copy link
Collaborator

Screen.Recording.2021-02-09.at.7.15.10.PM.mov

Example of the issue + the fix

@d-pollard d-pollard added has PR Has a related PR and removed additional-review-needed labels Feb 10, 2021
@qcyblm
Copy link

qcyblm commented Feb 10, 2021

@qcyblm if you could make sure that PR fixes it for you too, I would greatly appreciate it! #2794

Hello @d-pollard ,Test the site https://qcyblm.github.io/vuepress-CodeGroup/,
Local test, CodeBlock tab can not be displayed.

VuePress-CodeGroup

@d-pollard
Copy link
Collaborator

@qcyblm it looks good for me, it renders the code block

@d-pollard
Copy link
Collaborator

Screen_Recording_20210209-230334_Firefox.mp4

@qcyblm it shows this for me

@d-pollard
Copy link
Collaborator

Screen Shot 2021-02-09 at 11 12 51 PM

In chrome I get this too

@qcyblm
Copy link

qcyblm commented Feb 10, 2021

Screen Shot 2021-02-09 at 11 12 51 PM 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

Preview: http://localhost:8080/vuepress-CodeGroup/

@d-pollard
Copy link
Collaborator

@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?

@qcyblm
Copy link

qcyblm commented Feb 10, 2021

  • 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.

@qcyblm
Copy link

qcyblm commented Feb 10, 2021

@d-pollard - You can clone the vuepress-CodeGroup to make changes and pull requests to me, I do local testing.

@thecoden
Copy link

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!

@d-pollard
Copy link
Collaborator

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!

@qcyblm
Copy link

qcyblm commented Feb 10, 2021

My region is in China (it's 1:58 PM)

bencodezen pushed a commit that referenced this issue Feb 10, 2021
…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
@d-pollard
Copy link
Collaborator

Should be fixed as of https://github.com/vuejs/vuepress/releases/tag/v1.8.1

pwizla added a commit to strapi/documentation that referenced this issue Jun 16, 2021
Once [this issue]( vuejs/vuepress#2711) with
VuePress is fixed, we might be able to use the prettier code-groups
again :-)
pwizla added a commit to strapi/documentation that referenced this issue Jun 23, 2021
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has PR Has a related PR
Projects
None yet
Development

No branches or pull requests

4 participants