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

I can't get _sanityProps from within my custom component #824

Open
MooseSaeed opened this issue Jun 16, 2023 · 0 comments
Open

I can't get _sanityProps from within my custom component #824

MooseSaeed opened this issue Jun 16, 2023 · 0 comments
Labels
question Further information is requested

Comments

@MooseSaeed
Copy link

MooseSaeed commented Jun 16, 2023

I'm using v0.10.0 with nuxt 2. According to the docs, this nuxt module should:

be functionally equivalent to sanity-blocks-vue-component

I was using sanity-blocks-vue-component but I thought to use SanityContent component from this module and my code didn't work with it although it should be functionally equivalent.

The issue I'm having is that it doesn't pass any of Sanity props. For example, here's how I do marks and types using sanity-blocks-vue-component:

	this.serializers = {
		marks: {
			internalLink: props => {
				const newURL = `/article/${props.mark.slug}`
				const categoryURL = `/${props.mark.category}/${props.mark.slug}`

				let attrs = {
					href: this.linkFormatter(categoryURL)
				}

				attrs.target = '_blank'

				return this.$createElement('a', { attrs }, props.children)
			},
		},
		types: {
			customAd: CustomeAdComponent,
		}
	}

With sanity-blocks-vue-component, I was able to access internalLink sanity props (like this props.mark.slug) and create a custom mark and also I was able to use _sanityProps from inside my CustomeAdComponent. But with this nuxt module, I can't access any props.

Can someone please tell me why the above code doesn't work with this module? Or an extremely simple example to implement something similar to the above code would be highly appreciated.

@MooseSaeed MooseSaeed added the question Further information is requested label Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant