diff --git a/src/routes/articles/controllers/crud.ts b/src/routes/articles/controllers/crud.ts index 206877e..0a6b8a3 100644 --- a/src/routes/articles/controllers/crud.ts +++ b/src/routes/articles/controllers/crud.ts @@ -364,6 +364,7 @@ export async function importArticles(req: AuthRequest, res: Response) : Promise< // Шаг 3: Обработка массива images let updatedContent = newArticle.content; + if (article.images && Array.isArray(article.images) && article.images.length > 0) { const folder = `articles/${newArticle.id}/images`; const uploadedImageUrls: string[] = []; @@ -405,7 +406,7 @@ export async function importArticles(req: AuthRequest, res: Response) : Promise< uploadedImageUrls.forEach((uploadedUrl, index) => { if (uploadedUrl) { const placeholder = `{{image${index + 1}}}`; - const imgTag = ``; + const imgTag = `${article.imageSubs[index]}`; const regex = new RegExp(placeholder, 'g'); updatedContent = updatedContent.replace(regex, imgTag); } diff --git a/src/types/index.ts b/src/types/index.ts index f178e71..e5a6ec6 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -9,6 +9,7 @@ export interface Article { author: Author; coverImage: string; images?: string[]; + imageSubs: string[]; gallery?: GalleryImage[]; publishedAt: string; readTime: number;