Или хотя бы отобразить по ссылке на file.jpeg, сам file.gif
map $uri $gif {
default $uri;
~^(.*)\.jpeg$ "$1.gif";
}
server {
location @original {
try_files $image_folder_1$uri $image_folder_0$uri $image_folder_1$gif $image_folder_0$gif @errors;
}
function removeSomeShit(arr) {
const table = {};
const result = [];
for(const current of arr) {
const {uid, owner, createdAt} = current;
const uidOvnerKey = `${uid}\0${owner}`;
const ownerUidKey = `${owner}\0${uid}`;
const matched = table[uidOvnerKey];
if (matched) {
delete table[uidOvnerKey];
result.push(matched.createdAt > createdAt ? matched : current);
} else {
table[ownerUidKey] = current;
}
};
return Object.values(table).concat(result);
}
// _app.js
import {HeadProvider} from './HeadProvider';
function App({Component, pageProps}) {
return (
<HeadProvider>
<Component {...pageProps} />
</HeadProvider>
);
}
// HeadProvider.js
import React, {createContext, useContext, useState} from 'react';
const HeadContext = createContext();
export const useHead = () => useContext(HeadContext);
export function HeadProvider({children}) {
const [headData, setHeadData] = useState({
title: 'Init title',
description: 'Init description',
keywords: 'Init keywords'
});
return (
<HeadContext.Provider value={{headData, setHeadData}}>
{children}
</HeadContext.Provider>
);
}
// MyBestHead.js
import Head from 'next/head';
import {useHead} from './HeadProvider';
export function MyBestHead() {
const {headData} = useHead();
return (
<Head>
<title>{headData.title}</title>
<meta name="description" content={headData.description}/>
{/* more head items */}
</Head>
);
}
// MyComponent.js
import React, {useCallback} from 'react';
import {useHead} from './HeadProvider';
export function MyComponent() {
const {setHeadData} = useHead();
const handleClick = useCallback(() => {
setHeadData({
title: 'New title',
description: 'New description',
keywords: 'New keywords'
});
}, [setHeadData]);
return (
<button onClick={handleClick}>Update Head Data</button>
);
}
function isPermittedObject(obj) {
if (!obj) return false;
const permitted = new Set(["v", "c", "g"]);
let max = 1;
for (const key in obj)
if (!permitted.has(key) || !max--)
return false;
return true;
}
console.log(!isPermittedObject({
v: 1,
c: 3,
g: 5
}))
console.log(!isPermittedObject({
v: 1
}))
try_files $imgdir/$imgfile /../static$uri /../static1$uri /../static2$uri /../static3$uri @image;
setInterval(() => nextButton?.click(), 5000)
поместить внутрь второго if, то всё сработает, но лучше бы - логику по интервалу вынести в useEffect, а в handlePlay - менять только флаг стейта const arrs = [
[ 1, 2, 3, 4 ],
[ 5, 6, 7, 8 ],
[ 9, 10, 11 ],
];
const result = [];
const max = Math.max(...arrs.map(n => n.length));
const index = Array(arrs.length).fill(0);
for (let i = 0; i < max; i++) {
for (let j = 0; j < index.length; j++) {
if (index[j] < arrs[j].length) {
result[result.length] = arrs[j][index[j]++];
}
}
}
const result = arrs
.reduce((acc, arr) => (
arr.forEach((n, i) => (acc[i] ??= []).push(n)),
acc
), [])
.flat();