Fix widget order and positioning for a consistent user experience
Removes random shuffling of grid widgets and ensures the weather widget is correctly placed in the sidebar. Updates image URLs in `gallery-data.json`. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 517dfa7b-26ac-463d-a6e1-a58c6df97188 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: a6796d9a-0da8-4c8d-9a04-6c634aa173b3 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/f209e72a-0939-48fa-84fc-57854de71967/517dfa7b-26ac-463d-a6e1-a58c6df97188/nFw7xof Replit-Helium-Checkpoint-Created: true
This commit is contained in:
parent
daf7203739
commit
5f4266a662
@ -453,33 +453,14 @@ export default function Home() {
|
||||
return arr;
|
||||
}, [articles]);
|
||||
|
||||
const widgets = useMemo(() => {
|
||||
const w = [
|
||||
{ id: "recipe", el: <RecipeWidget key="recipe" /> },
|
||||
{ id: "horoscope", el: <HoroscopeWidget key="horoscope" /> },
|
||||
{ id: "gallery", el: <PhotoGalleryWidget key="gallery" /> },
|
||||
{ id: "news", el: <div key="news" className="flex flex-col gap-4"><NewsWidget /></div> },
|
||||
{ id: "breaking", el: <div key="breaking" className="flex flex-col gap-4"><BreakingNewsWidget /></div> },
|
||||
{ id: "gallery2", el: <PhotoGalleryWidget key="gallery2" reverseOrder={true} /> },
|
||||
];
|
||||
let valid = false;
|
||||
while (!valid) {
|
||||
for (let i = w.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[w[i], w[j]] = [w[j], w[i]];
|
||||
}
|
||||
valid = true;
|
||||
for (let i = 0; i < w.length - 1; i += 2) {
|
||||
const pair = [w[i].id, w[i + 1]?.id];
|
||||
if ((pair.includes("news") && pair.includes("breaking")) ||
|
||||
(pair.includes("gallery") && pair.includes("gallery2"))) {
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return w;
|
||||
}, []);
|
||||
const widgets = useMemo(() => [
|
||||
{ id: "horoscope", el: <HoroscopeWidget key="horoscope" /> },
|
||||
{ id: "news", el: <div key="news" className="flex flex-col gap-4"><NewsWidget /></div> },
|
||||
{ id: "gallery", el: <PhotoGalleryWidget key="gallery" /> },
|
||||
{ id: "recipe", el: <RecipeWidget key="recipe" /> },
|
||||
{ id: "breaking", el: <div key="breaking" className="flex flex-col gap-4"><BreakingNewsWidget /></div> },
|
||||
{ id: "gallery2", el: <PhotoGalleryWidget key="gallery2" reverseOrder={true} /> },
|
||||
], []);
|
||||
|
||||
const gridItems = useMemo(() => {
|
||||
const items: { type: "article" | "widget" | "ad"; key: string; article?: Article; widget?: typeof widgets[0] }[] = [];
|
||||
@ -554,10 +535,6 @@ export default function Home() {
|
||||
{ type: "ad", el: <div key="ad-bottom-1"><ArticleCardAd /></div> },
|
||||
{ type: "ad", el: <div key="ad-bottom-2"><ArticleCardAd /></div> },
|
||||
];
|
||||
for (let i = items.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[items[i], items[j]] = [items[j], items[i]];
|
||||
}
|
||||
return items;
|
||||
}, []);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user