Skip to content

Commit

Permalink
fix: weight calculation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Clovis committed Nov 3, 2024
1 parent 3028970 commit 6c242ea
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cms/src/helpers/formatPost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export function formatPost(post: Post) {
title: ${JSON.stringify(post.title)}
description: ${JSON.stringify(post.description)}
cover: ${JSON.stringify(post.cover)}
createdAt: ${JSON.stringify(post.createdAt.toISOString())}
updatedAt: ${JSON.stringify(post.updatedAt.toISOString())}
createdAt: ${JSON.stringify(post.createdAt?.toISOString())}
updatedAt: ${JSON.stringify(post.updatedAt?.toISOString())}
draft: ${JSON.stringify(post.draft)}
---
${post.content} `;
Expand Down
2 changes: 1 addition & 1 deletion cms/src/views/Post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const Post = ({ blank = false }: { blank?: boolean }) => {
} as IPost

const weight = new TextEncoder().encode(formatPost(data)).length;
setWeight(weight + parseInt(formData["cover-weight"] as string, 10));
setWeight(weight + (formData["cover-weight"] ? parseInt(formData["cover-weight"] as string, 10) : 0));
calculateImageWeight();
}, [calculateImageWeight, post]);

Expand Down

0 comments on commit 6c242ea

Please sign in to comment.