Skip to content

Commit

Permalink
Update random-color-theme.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Nov 21, 2024
1 parent 2db015c commit 39ca0bc
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions api/api/random-color-theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,12 @@ export default async function handler(request: Request) {
useCdn: false,
token: process.env.SANITY_API_WRITE_TOKEN,
})
const THEME_QUERY = defineQuery(`*[_id == "theme"][0]{_rev,background,text}`)
const THEME_QUERY = defineQuery(`*[_id == "theme"][0]{background,text}`)
const prevTheme = await client.fetch(THEME_QUERY, {}, {perspective: 'published'})
const _id = 'theme'
const nextTheme = generateThemeColors()
client
.patch(_id)
.ifRevisionId(prevTheme._rev)
.set(
// If the new theme is the same as the previous theme, swap the background and text colors
prevTheme?.background === nextTheme.background && prevTheme?.text === nextTheme.text
Expand Down

0 comments on commit 39ca0bc

Please sign in to comment.