Skip to content

Commit

Permalink
fix(module)!: export module as default to enable astro add (#151)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: This exposes the integration as a default export to enable `npx astro add @sanity/astro` as an installation method.

Installing this update requires changing the following in `astro.config.mjs`:
`-import { sanityIntegration } from '@sanity/astro'
`+import sanityIntegration from '@sanity/astro'`
  • Loading branch information
kmelve authored Mar 13, 2024
1 parent 5e9c011 commit ade3dba
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions apps/example-ssr/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { sanityIntegration } from '@sanity/astro'
import sanity from '@sanity/astro'
import { defineConfig } from 'astro/config'
import vercel from '@astrojs/vercel/serverless';
import react from '@astrojs/react';

// https://astro.build/config
export default defineConfig({
integrations: [
sanityIntegration({
sanity({
projectId: '3do82whm',
dataset: 'next',
// If you are doing static builds you may want opt out of the CDN
Expand Down
4 changes: 2 additions & 2 deletions apps/example/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { sanityIntegration } from "@sanity/astro";
import sanity from "@sanity/astro";
import { defineConfig } from "astro/config";
import react from '@astrojs/react';

// https://astro.build/config
export default defineConfig({
integrations: [
sanityIntegration({
sanity({
projectId: "3do82whm",
dataset: "next",
// If you are doing static builds you may want opt out of the CDN
Expand Down
4 changes: 2 additions & 2 deletions packages/sanity-astro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ You might have to restart the TS Server running in your code editor to get it to
Configure the integration in your `astro.config.mjs` file. The configuration options and methods are the same as for [@sanity/client](https://github.com/sanity-io/client#readme):

```typescript
import { sanityIntegration } from "@sanity/astro";
import sanity from "@sanity/astro";
import { defineConfig } from "astro/config";

// https://astro.build/config
export default defineConfig({
integrations: [
sanityIntegration({
sanity({
projectId: "<YOUR-PROJECT-ID>",
dataset: "<YOUR-DATASET-NAME>",
// Set useCdn to false if you're building statically.
Expand Down
2 changes: 1 addition & 1 deletion packages/sanity-astro/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const defaultOptions: IntegrationOptions = {
apiVersion: "v2023-08-24",
};

export function sanityIntegration(
export default function sanityIntegration(
options: IntegrationOptions,
): AstroIntegration {
const resolvedOptions = {
Expand Down
2 changes: 2 additions & 0 deletions packages/sanity-astro/src/studio/studio-route.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { StudioComponent } from "./studio-component"
export async function getStaticPaths() {
return [{ params: { path: "admin" } }]
}
export const prerender = true
---

<!doctype html>
Expand Down

0 comments on commit ade3dba

Please sign in to comment.