From 35791b430887dad8974192a4bf76639f324ce6fb Mon Sep 17 00:00:00 2001 From: anibilag Date: Fri, 2 May 2025 23:51:26 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BF=D0=BE=D0=B4=D0=BF=D0=B8=D1=81=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=B4=20=D0=B8=D0=B7=D0=BE=D0=B1=D1=80=D0=B0=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=D0=BC.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routes/articles/controllers/crud.ts | 3 ++- src/types/index.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) 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;