Skip to content

Commit

Permalink
chore(prettier): 🤖 ✨ (#44)
Browse files Browse the repository at this point in the history
Co-authored-by: ecospark[bot] <128108030+ecospark[bot]@users.noreply.github.com>
  • Loading branch information
ecospark[bot] authored Dec 12, 2024
1 parent bfa0d7a commit b5df2b6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
34 changes: 17 additions & 17 deletions astro/src/components/SanityLive.astro
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script>
import { navigate } from 'astro:transitions/client';
import {CorsOriginError} from '@sanity/client'
import { client } from '../sanity/client';
import {navigate} from 'astro:transitions/client'
import {client} from '../sanity/client'

const url = new URL(window.location.href)

const subscription = client.live.events().subscribe({
next: (event) => {
next: (event) => {
if (event.type === 'welcome') {
console.info('Sanity is live with automatic revalidation of published content')
} else if (event.type === 'message') {
Expand All @@ -19,17 +19,17 @@
navigate(url.toString(), {history: 'replace'})
}
},
error: (error: unknown) => {
if (error instanceof CorsOriginError) {
console.warn(
`Sanity Live is unable to connect to the Sanity API as the current origin - ${window.origin} - is not in the list of allowed CORS origins for this Sanity Project.`,
error.addOriginUrl && `Add it here:`,
error.addOriginUrl?.toString(),
)
} else {
console.error(error)
}
},
})
window.addEventListener('beforeunload', () => subscription.unsubscribe())
</script>
error: (error: unknown) => {
if (error instanceof CorsOriginError) {
console.warn(
`Sanity Live is unable to connect to the Sanity API as the current origin - ${window.origin} - is not in the list of allowed CORS origins for this Sanity Project.`,
error.addOriginUrl && `Add it here:`,
error.addOriginUrl?.toString(),
)
} else {
console.error(error)
}
},
})
window.addEventListener('beforeunload', () => subscription.unsubscribe())
</script>
4 changes: 2 additions & 2 deletions astro/src/layouts/Layout.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
import { ClientRouter } from 'astro:transitions';
import SanityLive from '../components/SanityLive.astro';
import {ClientRouter} from 'astro:transitions'
import SanityLive from '../components/SanityLive.astro'
---

<!doctype html>
Expand Down
2 changes: 1 addition & 1 deletion astro/src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
import {defineQuery} from 'groq'
import {sanityFetch} from '../sanity/fetch'
import Welcome from '../components/Welcome.astro'
import Layout from '../layouts/Layout.astro'
import {sanityFetch} from '../sanity/fetch'
export const prerender = false
Expand Down

0 comments on commit b5df2b6

Please sign in to comment.