More pages updated when content are updated

This commit is contained in:
DrMint 2022-04-16 20:12:49 +02:00
parent 1ddcd68286
commit 648446d267
1 changed files with 22 additions and 1 deletions

View File

@ -31,6 +31,11 @@ type HookContent = {
model: "content"; model: "content";
entry: { entry: {
slug: string; slug: string;
ranged_contents: [
{
slug: string;
}
];
}; };
}; };
@ -97,6 +102,7 @@ export default async function Mail(
case "library-item": { case "library-item": {
paths.push(`/library`); paths.push(`/library`);
paths.push(`/library/${body.entry.slug}`); paths.push(`/library/${body.entry.slug}`);
paths.push(`/library/${body.entry.slug}/scans`);
serverRuntimeConfig.locales?.map((locale: string) => { serverRuntimeConfig.locales?.map((locale: string) => {
paths.push(`/${locale}/library/${body.entry.slug}`); paths.push(`/${locale}/library/${body.entry.slug}`);
paths.push(`/${locale}/library/${body.entry.slug}/scans`); paths.push(`/${locale}/library/${body.entry.slug}/scans`);
@ -109,12 +115,27 @@ export default async function Mail(
} }
case "content": { case "content": {
console.log(body.entry.ranged_contents);
paths.push(`/contents`); paths.push(`/contents`);
paths.push(`/contents/${body.entry.slug}`); paths.push(`/contents/${body.entry.slug}`);
serverRuntimeConfig.locales?.map((locale: string) => { serverRuntimeConfig.locales?.map((locale: string) => {
paths.push(`/${locale}/contents/${body.entry.slug}`); paths.push(`/${locale}/contents/${body.entry.slug}`);
paths.push(`/${locale}/contents`); paths.push(`/${locale}/contents`);
}); });
if (body.entry.ranged_contents.length > 0) {
body.entry.ranged_contents.map((ranged_content) => {
const parentSlug = ranged_content.slug.slice(
0,
ranged_content.slug.length - body.entry.slug.length - 1
);
paths.push(`/library/${parentSlug}`);
paths.push(`/library/${parentSlug}/scans`);
serverRuntimeConfig.locales?.map((locale: string) => {
paths.push(`/${locale}/library/${parentSlug}`);
paths.push(`/${locale}/library/${parentSlug}/scans`);
});
});
}
break; break;
} }
@ -156,7 +177,7 @@ export default async function Mail(
break; break;
} }
//console.table(paths); console.table(paths);
try { try {
Promise.all( Promise.all(