From 7a851323d207b090f52c66d09f02a914fbd7e0df Mon Sep 17 00:00:00 2001 From: ifraimka Date: Fri, 8 Nov 2024 13:47:47 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=82=D0=B8=D0=BF=20=D0=BF=D0=BE=D1=81=D1=82=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=BF=D1=80=D0=BE=D0=B5=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=20=D0=B8=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D0=B9=20=D0=BD=D0=B0=20=D0=BE=D0=B1=D1=8A?= =?UTF-8?q?=D0=B5=D0=BA=D1=82,=20other=20=D0=BE=D1=81=D1=82=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=BC=D0=B0=D1=81=D1=81=D0=B8=D0=B2=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api.js | 10 ++++++---- src/pages/components/PagePost.jsx | 2 -- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/api.js b/src/api.js index ae23717..07ece25 100755 --- a/src/api.js +++ b/src/api.js @@ -100,9 +100,11 @@ async function loadPosts() { // Получаем записи const responsePosts = await getAllContent(wp.posts()); + // К проектам и лабораториям обращение по id, поэтому для быстроты чтения они - объекты + // Остальные посты (other) ищутся по категориям, это проще делать по массиву const result = { - projects: [], - labs: [], + projects: {}, + labs: {}, other: [], } @@ -120,10 +122,10 @@ async function loadPosts() { if (newPost.categories.includes('projects')) { newPost.lab = newPost.categories.filter(el => el !== 'projects')[0]; - result.projects.push(newPost); + result.projects[post.id] = newPost; } else if (newPost.categories.includes('labs')) { newPost.previewText = Parse(post.excerpt.rendered)[0].props.children; - result.labs.push(newPost); + result.labs[post.id] = newPost; } else { result.other.push(newPost); } diff --git a/src/pages/components/PagePost.jsx b/src/pages/components/PagePost.jsx index 9aebe8f..1ebdbc4 100644 --- a/src/pages/components/PagePost.jsx +++ b/src/pages/components/PagePost.jsx @@ -11,8 +11,6 @@ function PagePost({ post, isLab = false }) { {typeof post !== 'undefined' && typeof post.content !== 'string' && post.content.map(el => { - console.log(el.type); - console.log(el); if (el.type === 'mediablock') { return ; }