update featured news limit

This commit is contained in:
elise
2024-08-09 16:38:55 +02:00
parent bca4330373
commit 65100eff4e
2 changed files with 3 additions and 3 deletions

View File

@ -85,7 +85,7 @@ export default async function Home() {
<Pig type="point" /> <Pig type="point" />
</div> </div>
</div> </div>
<NewsList heading="Siste nytt" limit={4} featured news={news} /> <NewsList heading="Siste nytt" featured news={news} />
</main> </main>
); );
} }

View File

@ -14,7 +14,7 @@ export const NewsList = ({
heading?: string; heading?: string;
featured?: boolean; featured?: boolean;
}) => { }) => {
const [limit, setLimit] = useState(17); const [limit, setLimit] = useState(featured ? 4 : 17);
function increaseLimit() { function increaseLimit() {
setLimit(limit + 16); setLimit(limit + 16);
} }
@ -29,7 +29,7 @@ export const NewsList = ({
<NewsItem key={singleNews.id} news={singleNews} /> <NewsItem key={singleNews.id} news={singleNews} />
))} ))}
</ul> </ul>
{limit && news.length > limit && ( {!featured && limit && news.length > limit && (
<div className={styles.showMore}> <div className={styles.showMore}>
<button onClick={increaseLimit}> <button onClick={increaseLimit}>
<span>Last inn flere artikler</span> <span>Last inn flere artikler</span>