Skip to content

Commit

Permalink
chore(prettier): 🤖 ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Aug 9, 2023
1 parent 9932373 commit 906196b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion apps/example-ssr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

This example app is the same as the other example app in this repository, except with `output: 'server'` in the Astro configuration.

This example application renders the Sanity.io blog using Astro. It shows how to configure the Sanity + Astro integration in `astro.config.mjs`, querying and displaying Sanity content in `src/pages/index.astro` and `src/pages/posts/[slug].astro`, how to render PortableText in `src/components/PortableText.astro`, and how to present Sanity images in `src/components/SanityImage.astro`.
This example application renders the Sanity.io blog using Astro. It shows how to configure the Sanity + Astro integration in `astro.config.mjs`, querying and displaying Sanity content in `src/pages/index.astro` and `src/pages/posts/[slug].astro`, how to render PortableText in `src/components/PortableText.astro`, and how to present Sanity images in `src/components/SanityImage.astro`.
2 changes: 1 addition & 1 deletion apps/example/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Sanity + Astro example app

This example application renders the Sanity.io blog using Astro. It shows how to configure the Sanity + Astro integration in `astro.config.mjs`, querying and displaying Sanity content in `src/pages/index.astro` and `src/pages/posts/[slug].astro`, how to render PortableText in `src/components/PortableText.astro`, and how to present Sanity images in `src/components/SanityImage.astro`.
This example application renders the Sanity.io blog using Astro. It shows how to configure the Sanity + Astro integration in `astro.config.mjs`, querying and displaying Sanity content in `src/pages/index.astro` and `src/pages/posts/[slug].astro`, how to render PortableText in `src/components/PortableText.astro`, and how to present Sanity images in `src/components/SanityImage.astro`.
12 changes: 6 additions & 6 deletions packages/sanity-astro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ npx astro add @sanity/astro
Configure the integration in your `astro.config.mjs` file. The configuration options are the same as for @sanity/client.

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

// https://astro.build/config
export default defineConfig({
integrations: [
sanityIntegration({
projectId: '3do82whm',
projectId: "3do82whm",
dataset: "next",
useCdn: true
})
]
useCdn: true,
}),
],
});
```

Expand Down
32 changes: 16 additions & 16 deletions packages/sanity-astro/index.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
import type { AstroIntegration } from 'astro'
import type { SanityClient, ClientConfig } from '@sanity/client'
import { vitePluginSanityInit } from './vite-plugin-sanity-init'
import type { AstroIntegration } from "astro";
import type { SanityClient, ClientConfig } from "@sanity/client";
import { vitePluginSanityInit } from "./vite-plugin-sanity-init";
declare global {
var sanityClientInstance: SanityClient
var sanityClientInstance: SanityClient;
}

export function useSanityClient(): SanityClient {
if (!globalThis.sanityClientInstance) {
console.error('sanityClientInstance has not been initialized correctly')
console.error("sanityClientInstance has not been initialized correctly");
}
return globalThis.sanityClientInstance
return globalThis.sanityClientInstance;
}

export type IntegrationOptions = ClientConfig
export type IntegrationOptions = ClientConfig;

const defaultOptions: IntegrationOptions = {
apiVersion: 'v2021-03-25',
}
apiVersion: "v2021-03-25",
};

export default function sanityIntegration(
options: IntegrationOptions
): AstroIntegration {
const resolvedOptions = {
...defaultOptions,
...options,
}
};
return {
name: '@sanity/astro',
name: "@sanity/astro",
hooks: {
'astro:config:setup': ({ injectScript, updateConfig }) => {
"astro:config:setup": ({ injectScript, updateConfig }) => {
updateConfig({
vite: {
plugins: [vitePluginSanityInit(resolvedOptions)],
},
})
});

injectScript(
'page-ssr',
"page-ssr",
`
import { sanityClientInstance } from "virtual:sanity-init";
globalThis.sanityClientInstance = sanityClientInstance;
`
)
);
},
},
}
};
}
2 changes: 1 addition & 1 deletion packages/sanity-astro/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ export default defineConfig(() => {
}) as unknown as Plugin,
],
};
});
});

0 comments on commit 906196b

Please sign in to comment.