sanity-io / vscode-sanity

Visual Studio Code extension for developing applications powered by Sanity.io
MIT License
51 stars 9 forks source link

Is this Extension still maintained? #19

Closed AJMcKane closed 3 months ago

AJMcKane commented 1 year ago

Hi there,

I'm currently learning sanity and utilising it within a Nuxt.js application, so far the docs have been really helpful, but I can't get this extension to do anything. The official docs say I need a sanity.json file, but that's not the case with the Nuxt consumer, as it's configured as part of the Nuxt config, rather than in a standalone file?

And direction would be appreciated.

MartCube commented 1 year ago

I would also like to see how to connect the sanity.json file so I can execute my queries right away

mthomes commented 8 months ago

sanity.json file needs to exists in the root of your project. With this content.

{
  "api": {
    "projectId": "{projectId}",
    "dataset": "{dataset}"
  }
}
runeb commented 3 months ago

Apologies for the delay on this. The plugin only supported v2 of Sanity which had a different configuration format. We have now updated the plugin to support the newer sanity.cli.js|ts config file.

mthomes commented 3 months ago

@runeb When I run the query I get an error of:

Configuration must contain `projectId`

When I try and run a query now using the sanity.cli.ts file. It's using env variables:

import {defineCliConfig} from 'sanity/cli';

const projectId = process.env.SANITY_STUDIO_PROJECT_ID;
const dataset = process.env.SANITY_STUDIO_DATASET;

export default defineCliConfig({api: {projectId, dataset}});

When I hard code them It's resolved.