Revalidate videos
This commit is contained in:
parent
6a1be38613
commit
4a71f897a8
|
@ -1,6 +1,6 @@
|
|||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
import { i18n } from "../../../next.config";
|
||||
import { cartesianProduct, filterHasAttributes } from "helpers/others";
|
||||
import { cartesianProduct, filterHasAttributes, isDefined } from "helpers/others";
|
||||
import { fetchLocalData } from "graphql/fetchLocalData";
|
||||
import { getReadySdk } from "graphql/sdk";
|
||||
|
||||
|
@ -26,6 +26,7 @@ type RequestProps =
|
|||
| StrapiLibraryItem
|
||||
| StrapiPostContent
|
||||
| StrapiRangedContent
|
||||
| StrapiVideo
|
||||
| StrapiWebsiteInterface
|
||||
| StrapiWiki;
|
||||
|
||||
|
@ -134,6 +135,15 @@ interface StrapiChronicleChapter extends StrapiEvent {
|
|||
};
|
||||
}
|
||||
|
||||
interface StrapiVideo extends StrapiEvent {
|
||||
event: CRUDEvents;
|
||||
model: "video";
|
||||
entry: {
|
||||
uid: string;
|
||||
channel: StrapiRelationalField;
|
||||
};
|
||||
}
|
||||
|
||||
type ResponseProps = {
|
||||
message: string;
|
||||
revalidated: boolean;
|
||||
|
@ -293,6 +303,19 @@ const Revalidate = async (
|
|||
break;
|
||||
}
|
||||
|
||||
case "video": {
|
||||
if (body.entry.uid) {
|
||||
paths.push(`/archives/videos`);
|
||||
paths.push(`/archives/videos/v/${body.entry.uid}`);
|
||||
const video = await sdk.getVideo({ uid: body.entry.uid });
|
||||
const channelUid = video.videos?.data[0].attributes?.channel?.data?.attributes?.uid;
|
||||
if (isDefined(channelUid)) {
|
||||
paths.push(`/archives/videos/c/${channelUid}`);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "custom": {
|
||||
paths.push(`${body.path}`);
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue