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

.asHtml not recognized in prismicH.asHtml (using Vite, Vue 3 and Nuxt 3) #68

Open
carbdias opened this issue Nov 21, 2023 · 2 comments
Open
Labels
bug Something isn't working

Comments

@carbdias
Copy link

carbdias commented Nov 21, 2023

Hello, I'm having an issue while implementing prismic-helpers in replacement of old prismic-dom library.
Also I wanted to check if it is compatible with Vite and Nuxt 3, because after implementing all the changes I'm having

[nuxt] [request error] [unhandled] [500] vite_ssr_import_0.asHtml is not a function
at Proxy.dynamicComponent (./src/components/content/PrismicField.vue:47:48)
at ReactiveEffect.run (./node_modules/@vue/reactivity/dist/reactivity.cjs.js:162:19)
at get value [as value] (./node_modules/@vue/reactivity/dist/reactivity.cjs.js:1131:33)
at Object.get [as dynamicComponent] (./node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:3410:22)
at _sfc_ssrRender (./src/components/content/PrismicField.vue:89:136)
at renderComponentSubTree (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:683:9)
at renderComponentVNode (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:631:12)
at renderVNode (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:743:14)
at renderVNodeChildren (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:759:5)
at renderElementVNode (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:806:9)

when I try to call this method the new way :

       ${prismicH.asHtml(
           this.field,
           // null param because this prismic function need normaly a link-resolver param
           // doc : https://prismic.io/docs/javascript/templating/rich-text
           // but we put the link-resolver in the back-end so we do no longer need link-resolver in front
           null,
           htmlSerializer
      )}</div>`,
      
      I have the import here in the vue file 
      import * as prismicH from '@prismicio/helpers';
      
      and I also have the htmlSerializer defined in another file.
      
      But the error comes right away when calling prismicH.asHtml.
      
      What should I do ?
      


PS: Package.json is like this :
      
"devDependencies": {
      "@nuxt/devtools": "latest",
      "nuxt": "^3.8.1",
      "sass": "^1.69.5",
      "sass-loader": "^13.3.2",
      "vue": "^3.3.8",
      "vue-router": "^4.2.5"
  },
"dependencies": {
      "@bootstrap-vue-next/nuxt": "^0.14.10",
      "@nuxtjs/i18n": "^8.0.0-rc.5",
      "@pinia/nuxt": "^0.5.1",
      "@popperjs/core": "^2.11.8",
      "@prismicio/helpers": "^2.3.9",
      "bootstrap": "^5.3.2",
      "bootstrap-vue-next": "^0.14.10",
      "nuxt-jsonld": "^2.0.8",
      "vite-svg-loader": "^4.0.0"
}
@carbdias carbdias added the bug Something isn't working label Nov 21, 2023
Copy link

This issue has been labeled as a bug since it was created using the 🚨 Bug Report Template.

Hi there, thank you so much for the report!

Following our Maintenance Process, we will review your bug report and get back to you next Wednesday. To ensure a smooth review of your issue and avoid unnecessary delays, please make sure your issue includes the following:

  • Information about your environment and packages you use (Node.js version, package names and their versions, etc.)
    Feel free to attach a copy of your package.json file.
  • Any troubleshooting steps you already went through
  • A minimal reproduction of the issue, and/or instructions on how to reproduce it

If you have identified the cause of the bug described in your report and know how to fix it, you're more than welcome to open a pull request addressing it. Check out our quick start guide for a simple contribution process.

If you think your issue is a question (not a bug) and would like quicker support, please close this issue and forward it to an appropriate section on our community forum: https://community.prismic.io

- The Prismic Open-Source Team

@carbdias
Copy link
Author

Hello, any news on this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant