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