Skip to content
This repository has been archived by the owner on Jan 7, 2024. It is now read-only.

SSR demo #10

Merged
merged 2 commits into from
Dec 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion demo-ssr/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,10 @@ import sanity from 'astro-sanity'
export default defineConfig({
output: 'server',
adapter: vercel(),
integrations: [image()],
integrations: [image(), sanity({
projectId: '8hj1t7km',
dataset: 'production',
apiVersion: '2021-03-25',
useCdn: true
})],
});
4 changes: 2 additions & 2 deletions demo-ssr/src/sanity/api.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { sanityClient } from './client.js';
import { useSanityClient } from 'astro-sanity';
import { groq } from 'astro-sanity';

export async function getFirstBlogPost() {
const query = groq`*[_type == "post" && _id == "0b3a877f-9ede-4360-a7b0-dee96107215e"][0]`;
const firstPost = await sanityClient.fetch(query);
const firstPost = await useSanityClient().fetch(query);
return firstPost;
}
8 changes: 0 additions & 8 deletions demo-ssr/src/sanity/client.js

This file was deleted.

4 changes: 2 additions & 2 deletions demo-ssr/src/sanity/urlForImage.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { sanityClient } from './client.js';
import { useSanityClient } from 'astro-sanity';
import { createImageBuilder } from 'astro-sanity';

export const imageBuilder = createImageBuilder(sanityClient);
export const imageBuilder = createImageBuilder(useSanityClient());

export function urlForImage(source) {
return imageBuilder.image(source);
Expand Down