-
Notifications
You must be signed in to change notification settings - Fork 35
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
Support for using the configured Sanity client in nuxt.config.js
#3
Comments
nuxt.config.js
This is an interesting idea. Would importing a Proposed use: import { createClient } from '@nuxtjs/sanity'
const client = createClient()
export default {
// ...
} |
Yes, that would perfect for my use case 👍 |
I had a look at the code. Actually there's already a helper function exported. So I can do this: import { createClient } from '@nuxtjs/sanity'
export const configSanity = {
projectId: 'xxxxxxx',
withCredentials: true,
useCdn: false,
minimal: true,
}
const client = createClient(configSanity)
export default {
// nuxt config....
sanity: {
...configSanity,
},
} I see that only the main nuxtModule function has access to the moduleOptions. So I guess it's not that easy to export an auto-configured client? If I want to submit a contribution with this enhancement, where should I start in the code? |
+1 to this idea |
The // for minimal client
import { createClient } from '@nuxtjs/sanity'
// for official Sanity client
import createClient from '@sanity/client'
const client = createClient({
projectId: 'xxxxxxx',
withCredentials: true,
useCdn: false,
})
// ... use client Do you think this is straightforward enough? It doesn't feel that inconvenient to me, but I'm open to being persuaded otherwise. |
Yes, this is what I'm doing and it's perfectly fine 😉 I'll submit a pull request to document it. |
When generating dynamic routes, I need the Sanity client to fetch all routes. Is there a way I can access the configured client in nuxt.config.js? Or do I need to import it and configure it again?
The text was updated successfully, but these errors were encountered: