Skip to content

Commit

Permalink
fix: remove landing if check
Browse files Browse the repository at this point in the history
  • Loading branch information
Aerilym committed Oct 14, 2024
1 parent ce28368 commit e19745e
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions packages/sanity-cms/api/revalidate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import logger from '../lib/logger';
import { safeTry } from '@session/util-js/try';
import type { PageSchemaType } from '../schemas/page';
import type { PostSchemaType } from '../schemas/post';
import { getSiteSettings } from '../queries/getSiteSettings';
import type { SessionSanityClient } from '../lib/client';

type RssGeneratorConfig = {
Expand Down Expand Up @@ -141,14 +140,8 @@ export const createRevalidateHandler = ({
if (!schemaUrl.endsWith('/')) {
schemaUrl = `${schemaUrl}/`;
}
const settings = await getSiteSettings({ client });
if (slug === settings?.landingPage?.slug?.current) {
revalidatePath(`${schemaUrl}`);
} else {
revalidatePath(`${schemaUrl}${slug}`);
// Also revalidate the root schema url (if it's not the landing page) Eg: /blog
revalidatePath(schemaUrl.replaceAll('/', ''));
}
revalidatePath(`${schemaUrl}`);
revalidatePath(`${schemaUrl}${slug}`);
}
}
}
Expand Down

0 comments on commit e19745e

Please sign in to comment.