-
Notifications
You must be signed in to change notification settings - Fork 6
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
Not working with SvelteKit #3
Comments
I made a demo here |
It might be more related to Svetkit and how it deals with imports. I'm leaving the link here if someone is interested to try it out and see how to make Svelkit and PortableText work together. |
Same issue here. I just can't get this working. |
The workaround is to use the dep optimization options in vite: {
optimizeDeps: {
include: ['@sanity/block-content-to-hyperscript/internals']
} |
Your optimizeDeps trick sorted out the issue for me, thanks! For simplicity and reference for others, my
|
Although this seemed to work, the error went away and content was properly rendered with Switching to <script>
import Link from '$lib/Link.svelte'
</script>
<PortableText
blocks={post.body}
serializers={{
marks: {
link: Link
}
}}
/> with <script>
export let portableText
</script>
<a href={portableText.mark.href}>
<slot />
</a> Which then yielded my desired results, correct tags and links with href attributes. Special thanks to @hdoro for sharing this solution in his upcoming SvelteKit Blog Sanity template. |
@taocode I'm yet to add default rendering of links, upon which you won't have to manually specify this unless your link's data structure is different 😉 Do reach out in Slack if you (or others) have any questions, it'll be a pleasure to help o/ |
I did a test with Sveltkit and I'm getting this error:
All packages are installed as
devDependencies
, and thePortableText
component is installed with theblock-content-to-hyperscript
package.The text was updated successfully, but these errors were encountered: