Add revalidation for weapon stories and groups

This commit is contained in:
DrMint 2023-02-22 06:12:58 +01:00
parent a0706fd52f
commit 0420dc30a4
2 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,15 @@
query revalidationGetWeaponGroup($id: ID) {
weaponStoryGroup(id: $id) {
data {
attributes {
weapons(pagination: { limit: -1 }) {
data {
attributes {
slug
}
}
}
}
}
}
}

View File

@ -28,6 +28,8 @@ type RequestProps =
| StrapiPostContent
| StrapiRangedContent
| StrapiVideo
| StrapiWeaponGroup
| StrapiWeaponStory
| StrapiWebsiteInterface
| StrapiWiki;
@ -36,6 +38,21 @@ interface CustomRequest {
path: string;
}
interface StrapiWeaponStory extends StrapiEvent {
model: "weapon-story";
entry: {
slug: string;
};
}
interface StrapiWeaponGroup extends StrapiEvent {
model: "weapon-story-group";
entry: {
id: string;
slug: string;
};
}
interface StrapiRangedContent extends StrapiEvent {
event: CRUDEvents;
model: "ranged-content";
@ -311,6 +328,21 @@ const Revalidate = async (
break;
}
case "weapon-story": {
paths.push(`/wiki/weapons/${body.entry.slug}`);
break;
}
case "weapon-story-group": {
const group = await sdk.revalidationGetWeaponGroup({
id: body.entry.id,
});
filterHasAttributes(group.weaponStoryGroup?.data?.attributes?.weapons?.data, [
"attributes.slug",
] as const).forEach((weapon) => paths.push(`/wiki/weapons/${weapon.attributes.slug}`));
break;
}
case "custom": {
paths.push(`${body.path}`);
break;