fix: skip saving comments files when post has zero comments

This commit is contained in:
@gapmiss 2026-06-22 16:42:16 -05:00
parent b5aaa9a1a9
commit e93ca869d4

View file

@ -108,12 +108,12 @@ export default class SubstackClipperPlugin extends Plugin {
try {
const commentsData = await fetchComments(domain, article.id, this.settings.commentSort);
if (this.settings.saveRawJson) {
const commentsJsonPath = normalizePath(`${saveDir}/${slug}-comments.json`);
await this.writeFile(commentsJsonPath, JSON.stringify(commentsData, null, 2));
}
if (commentsData.comments && commentsData.comments.length > 0) {
if (this.settings.saveRawJson) {
const commentsJsonPath = normalizePath(`${saveDir}/${slug}-comments.json`);
await this.writeFile(commentsJsonPath, JSON.stringify(commentsData, null, 2));
}
const commentsMd = renderComments(commentsData, slug, domain);
const commentsPath = normalizePath(`${this.settings.saveDirectory}/${username}/${slug}-comments.md`);
await this.writeFile(commentsPath, commentsMd);