From a4b2a5da7204ceb628ef59a6f1e41a0ebdf89e77 Mon Sep 17 00:00:00 2001 From: Graeme Fulton Date: Wed, 29 May 2024 10:32:02 -0400 Subject: [PATCH] show correct order of tools on homepage, stop user nav flicker --- components/BusinessNav.js | 4 +- components/EditorNav.js | 4 +- components/Navbar/Navbar.jsx | 2 +- components/Navbar/NavbarApp.js | 2 +- components/navbar-menu.js | 2 +- components/navbar2.js | 6 +- components/small-nav.js | 2 +- .../v4/card/BigCard/BigBackgroundCard.js | 3 +- components/v4/layout/CardColumn.js | 2 +- lib/locale/transformLocale.js | 2 +- lib/utils/groupPostsByDate.js | 2 +- lib/utils/postUtils.js | 2 +- pages/index.js | 88 ++++++++++++------- 13 files changed, 71 insertions(+), 50 deletions(-) diff --git a/components/BusinessNav.js b/components/BusinessNav.js index 7d9a806f..5c0eb2c6 100644 --- a/components/BusinessNav.js +++ b/components/BusinessNav.js @@ -150,7 +150,7 @@ export default function BusinessNav({ showJobsButton={showJobsButton} hideLocaleSwitcher={true} user={user} - userLoading={isLoading} + userLoading={false} userLoggedInCookie={userLoggedInCookie} activeNav={activeNav} editor={isEditor} @@ -170,7 +170,7 @@ export default function BusinessNav({ diff --git a/components/EditorNav.js b/components/EditorNav.js index 585071c8..aadec5a3 100644 --- a/components/EditorNav.js +++ b/components/EditorNav.js @@ -124,7 +124,7 @@ export default function EditorNav({ activeNav, postStatus }) { showJobsButton={false} hideLocaleSwitcher={true} user={user} - userLoading={isLoading} + userLoading={false} userLoggedInCookie={userLoggedInCookie} activeNav={activeNav} editor={true} @@ -144,7 +144,7 @@ export default function EditorNav({ activeNav, postStatus }) { diff --git a/components/Navbar/Navbar.jsx b/components/Navbar/Navbar.jsx index 89d730ce..d650032e 100644 --- a/components/Navbar/Navbar.jsx +++ b/components/Navbar/Navbar.jsx @@ -195,7 +195,7 @@ const Navbar = ({
- +
{sponsor?:null}
 
diff --git a/components/Navbar/NavbarApp.js b/components/Navbar/NavbarApp.js index 91883d90..52f4b6b7 100644 --- a/components/Navbar/NavbarApp.js +++ b/components/Navbar/NavbarApp.js @@ -197,7 +197,7 @@ const Navbar = ({
- +
{sponsor?:null}
 
diff --git a/components/navbar-menu.js b/components/navbar-menu.js index c04d953a..cb416126 100644 --- a/components/navbar-menu.js +++ b/components/navbar-menu.js @@ -225,7 +225,7 @@ export const NavigationMenuDemo = ({ {user && user?.isLoggedIn ? (
{/* */} - {user ? : ""} + {user ? : ""} {/* {user && @@ -165,7 +165,7 @@ export default function Navbar({ activeNav }) {
@@ -180,7 +180,7 @@ export default function Navbar({ activeNav }) { diff --git a/components/small-nav.js b/components/small-nav.js index ac16ca9d..38a4b265 100644 --- a/components/small-nav.js +++ b/components/small-nav.js @@ -140,7 +140,7 @@ export default function Navbar({ activeNav }) { diff --git a/components/v4/card/BigCard/BigBackgroundCard.js b/components/v4/card/BigCard/BigBackgroundCard.js index b75052cf..4e26b482 100644 --- a/components/v4/card/BigCard/BigBackgroundCard.js +++ b/components/v4/card/BigCard/BigBackgroundCard.js @@ -4,6 +4,7 @@ import Avatar from "../../avatar/Avatar"; import MediumTag from "../../tag/MediumTag"; import gumletLoader from "@/components/new-index/gumletLoader"; import Moment from "react-moment"; +const defaultBase64 = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAABLCAQAAAA1k5H2AAAAi0lEQVR42u3SMQEAAAgDoC251a3gL2SgmfBYBRAA`; // layouts: 1 is big image // 2 is small image @@ -35,7 +36,7 @@ const BigBackgroundCard = ({
- {tools.slice(3, tools.length - 1).map((tool, index) => { + {tools.slice(2, tools.length - 1).map((tool, index) => { return (
{index !== 0 ? ( diff --git a/lib/locale/transformLocale.js b/lib/locale/transformLocale.js index 5e607e98..68fa8b1a 100644 --- a/lib/locale/transformLocale.js +++ b/lib/locale/transformLocale.js @@ -68,7 +68,7 @@ export const transformPost =(post, locale) =>{ */ export const transformPostListOld = (postList, locale) =>{ - for (var i =0;i { + posts?.forEach(post => { const postDate = new Date(post.attributes?.date); const postDateStart = new Date(postDate.getFullYear(), postDate.getMonth(), postDate.getDate()); diff --git a/lib/utils/postUtils.js b/lib/utils/postUtils.js index 46f58657..42f3d533 100644 --- a/lib/utils/postUtils.js +++ b/lib/utils/postUtils.js @@ -29,7 +29,7 @@ function authorExists(authors, slug) { // https://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array export const shuffleArray = (array)=> { - for (var i = array.length - 1; i > 0; i--) { + for (var i = array?.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = array[i]; array[i] = array[j]; diff --git a/pages/index.js b/pages/index.js index ff1977bd..45f96129 100644 --- a/pages/index.js +++ b/pages/index.js @@ -92,7 +92,6 @@ export default function Index({ // const jobsSidebar = jobs.filter((item, i) => i !== 0); const toolsList = allTools; - return ( <> - {!user?.isLoggedIn ? ( + {!user?.isLoggedIn ? ( <> {/*
-

- New Posts +

+ New Posts

@@ -206,7 +205,9 @@ export default function Index({
- + {toolsList?.length > 0 ? ( + + ) : null} {/* */} @@ -216,8 +217,12 @@ export default function Index({ 3 ? morePosts[4] : null} + viewablePosts={ + morePosts?.length > 5 + ? morePosts.slice(5, morePosts.length) + : null + } showBigPost={2} showTitle={false} /> @@ -322,7 +327,10 @@ export default function Index({ {/* */} {TAB_ITEMS?.map((topic, index) => { return ( -
+
{/* */} @@ -362,7 +375,6 @@ export default function Index({
); })} -
{/* @@ -395,11 +407,14 @@ export async function getStaticProps({ preview = null, locale }) { "date:desc", ])) || []; - - for (var x=0;x 1 ? allPosts.slice(1) : null, + allTools: allTools?.length ? allTools : null, + allNews: allNews?.length ? allNews : null, + groupedNewsPosts: groupedNewsPosts ? groupedNewsPosts : null, // popularTags, // otherPosts: otherPosts, // interviewPosts: interviews.data, - topicRes, + topicRes: topicRes ? topicRes : null, preview, // jobs, // randomPosts: randomPosts.slice(0, 8),