We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d8582b3 commit 9d42804Copy full SHA for 9d42804
1 file changed
app/api/posts/[slug]/route.ts
@@ -47,9 +47,17 @@ export async function PUT(
47
const body = await req.json();
48
const post = await Post.findOne({ slug: params.slug });
49
50
+ let thumbnailOfPost = getThumbnailInMarkdown(body.content);
51
+ if (!thumbnailOfPost) {
52
+ const seriesThumbnail = await Series.findById(body.seriesId).select('thumbnailImage');
53
+ thumbnailOfPost =
54
+ seriesThumbnail?.thumbnailImage ||
55
+ '/images/placeholder/thumbnail_example2.webp';
56
+ }
57
+
58
const updatedPost = await Post.findOneAndUpdate(
59
{ slug: params.slug },
- { ...body, thumbnailImage: getThumbnailInMarkdown(body.content) },
60
+ { ...body, thumbnailImage: thumbnailOfPost },
61
{
62
new: true,
63
runValidators: true,
0 commit comments