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

fix(nuxt): do not render app pages alongside stories (fixes #472) #473

Merged
merged 2 commits into from
Mar 16, 2023

Conversation

medfreeman
Copy link
Contributor

@medfreeman medfreeman commented Mar 6, 2023

Description

Fixes #472

This PR stops @histoire/plugin-nuxt from rendering whatever is in nuxt app template under each story and the whole histoire page itself.
It does so by injecting an empty compiled vue template instead of the app template.
It also disables pages in nuxt.config for the plugin not to try rendering the app routes, which avoids vue-router errors in console and the rendering of 404s in place of the extra app template.

Additional context

Please tell me if i should write a test that checks that nuxt app template / 404s don't render alongside stories.
Perhaps by checking there's no additional content instead of looking for specific content.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • If it's a new feature, provide a convincing reason to add it. Ideally, you should open a suggestion issue first and have it approved before working on it.
  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@codesandbox
Copy link

codesandbox bot commented Mar 6, 2023

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@stackblitz
Copy link

stackblitz bot commented Mar 6, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@netlify
Copy link

netlify bot commented Mar 6, 2023

Deploy Preview for histoire-examples-svelte3 ready!

Name Link
🔨 Latest commit 9664285
🔍 Latest deploy log https://app.netlify.com/sites/histoire-examples-svelte3/deploys/640b1f700cd8f500088fa824
😎 Deploy Preview https://deploy-preview-473--histoire-examples-svelte3.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 6, 2023

Deploy Preview for histoire-examples-vue3 ready!

Name Link
🔨 Latest commit 9664285
🔍 Latest deploy log https://app.netlify.com/sites/histoire-examples-vue3/deploys/640b1f7029a9370008b20db9
😎 Deploy Preview https://deploy-preview-473--histoire-examples-vue3.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 6, 2023

Deploy Preview for histoire-controls ready!

Name Link
🔨 Latest commit 9664285
🔍 Latest deploy log https://app.netlify.com/sites/histoire-controls/deploys/640b1f700ad1d4000849727e
😎 Deploy Preview https://deploy-preview-473--histoire-controls.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 6, 2023

Deploy Preview for histoire-site ready!

Name Link
🔨 Latest commit 9664285
🔍 Latest deploy log https://app.netlify.com/sites/histoire-site/deploys/640b1f70e7c66700080e494d
😎 Deploy Preview https://deploy-preview-473--histoire-site.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@medfreeman medfreeman changed the title fix(nuxt): do not render app pages alongside stories (fix #472) fix(nuxt): do not render app pages alongside stories (fixes #472) Mar 6, 2023
@Akryum
Copy link
Member

Akryum commented Mar 9, 2023

Thanks! Maybe a test would be nice so we don't get unexpected regression with Nuxt in the future 👍

@medfreeman
Copy link
Contributor Author

I've added a test, which passes w/ the fix and doesn't w/o, on both actual and latest nuxt versions.

Side question: is it wanted that the nuxt app both renders in each story and on the whole histoire page additionally?
Does and shall setupCode run for both cases?

Copy link
Member

Akryum commented Mar 13, 2023

Yes because in some cases (e.g. grids) there are no iframes.

@Akryum Akryum merged commit 50aebae into histoire-dev:main Mar 16, 2023
@medfreeman medfreeman deleted the fix-nuxt-vue-router-errors branch March 16, 2023 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Latest releases of Histoire and Nuxt are not compatible
2 participants